Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
infra:howto:apptainer_sample [2024/12/12 14:05] – created remiinfra:howto:apptainer_sample [2025/03/03 10:24] (current) remi
Line 48: Line 48:
  
 Of course, you can tailor this to fit your needs.  Of course, you can tailor this to fit your needs. 
 +
 +Check the [[ https://apptainer.org/docs/user/latest/build_a_container.html | complete Apptainer documentation ]] for more details.
  
  
Line 65: Line 67:
  
  
 +
 +## Migrating from Docker
 +
 +When you already have a Docker image for your job, you have several options to migrate to Apptainer :
 +
 +### From Dockerhub
 +If you have your image ready on DockerHub, then you can simply run from the server :
 +  ```bash
 +  apptainer build ./datasets/yourapplication.sif docker://yourapplication:latest
 +       
 +INFO:    Starting build...
 +Copying blob 5a7813e071bf done   
 +Copying config a04dc4851c done   
 +Writing manifest to image destination
 +2025/03/03 11:17:45  info unpack layer: sha256:5a7813e071bfadf18aaa6ca8318be4824a9b6297b3240f2cc84c1db6f4113040
 +INFO:    Creating SIF file...
 +INFO:    Build complete: ./datasets/yourapplication.sif
 +
 +  ```
 +
 +### From local image
 +You can convert your image to an Apptainer .sif **on your local laptop** before uploading your .sif to the server : 
 +
 +  1. From local docker images :
 +  ```bash
 +  sudo apptainer build yourapplication.sif docker-daemon://yourapplication:latest
 +  
 +  [sudo] password for user.name: 
 +  INFO:    Starting build...
 +  Copying blob 27123a71e85e done   
 +  Copying config 388ea0fa6e done   
 +  Writing manifest to image destination
 +  2025/03/03 10:43:58  info unpack layer: sha256:bec6fac0671f72331024c0537184f7213dd7940aa9f6bf20cb8a30bdb2e35b1d
 +  INFO:    Creating SIF file...
 +  INFO:    Build complete: yourapplication.sif
 +  
 +  scp yourapplication.sif user.name@chacha:/home/user.name/datasets/
 +  ```
 +  
 +  2. You can also build the .sif from a docker archive :
 +  ```bash
 +sudo docker save yourapplication:latest -o yourapplication.tar
 +
 +sudo chown user.name: yourapplication.tar
 +
 +apptainer build yourapplication.sif docker-archive://yourapplication.tar
 +INFO:    Starting build...
 +Copying blob 27123a71e85e done   
 +Copying config 388ea0fa6e done   
 +Writing manifest to image destination
 +2025/03/03 10:54:47  info unpack layer: sha256:bec6fac0671f72331024c0537184f7213dd7940aa9f6bf20cb8a30bdb2e35b1d
 +INFO:    Creating SIF file...
 +INFO:    Build complete: yourapplication.sif
 +
 +scp yourapplication.sif user.name@chacha:/home/user.name/datasets/
 +```
 +
 +### From Dockerfile
 +
 +You can convert your Docker file to an Apptainer definition file using this conversion table : https://apptainer.org/docs/user/main/docker_and_oci.html#sec-deffile-vs-dockerfile
 +
 +TODO: Script a converter
  
Back to top