name: title layout: true class: center --- layout: false count: false .center[
https://www.nipreps.org/assets/fmriprep-bootcamp-geneva2024/day1-04-containers/
## Containers Chris Markiewicz <
markiewicz@stanford.edu
> Oscar Esteban <
phd@oscaresteban.es
> ] --- name: newsection layout: true .perma-sidebar[
Day 1 :: Containers
] --- # Outlook .right-column3.center[
https://www.nipreps.org/assets/fmriprep-bootcamp-geneva2024/day1-04-containers/
] .left-column3[ .large[
* What are containers and why researchers care? * Docker * Apptainer ]] ??? ---
.boxed-content[ .large.center[ # What are containers? ] .large.center.gray-text[Why do we care?] ] ---
.boxed-content[ .large[ *A container is a unit of software that packages code with its required dependencies in order to run in an isolated, controlled environment. This allows you to run an application in a way that is predictable, repeatable, and without the uncertainty of inconsistent code execution across diverse development and production environments. A container will always start up and run code the same way, regardless of what machine it exists on.* ] .large.center.gray-text[https://www.digitalocean.com/community/conceptual-articles/introduction-to-containers] ] --- count:false
.boxed-content[ .large[ *A container is a unit of software that packages
code with
its required
dependencies
in order to run in an
isolated
, controlled environment. This allows you to run an application in a way that is
predictable, repeatable
, and without the uncertainty of inconsistent code execution across diverse development and production environments. A container will always start up and run code the same way,
regardless of what machine
it exists on.* ] .large.center.gray-text[https://www.digitalocean.com/community/conceptual-articles/introduction-to-containers] ] --- count:false
.boxed-content[ .large[ *A container is a unit of software that packages code with its required dependencies in order to run in an isolated, controlled environment. This allows you to run an application in a way that is predictable,
repeatable
, and without the uncertainty of inconsistent code execution across diverse development and production environments. A container will always start up and run code the same way, regardless of what machine it exists on.* ] .large.center.gray-text[https://www.digitalocean.com/community/conceptual-articles/introduction-to-containers] ] --- # Isn't this the same as virtual machines?
.boxed-content[
![:img containers-vs-vms, 100%](https://wac-cdn.atlassian.com/dam/jcr:92adde69-f728-4cfc-8bab-ba391c25ae58/SWTM-2060_Diagram_Containers_VirtualMachines_v03.png?cdnVersion=2218)
From
the Atlassian documentation
] ---
.boxed-content[ .large.center[ #
Docker] ] --- # First contact with docker .boxed-content.pad-top[
] --- # Container Images .boxed-content.pad-top[ .no-bullet[ * .large[
Images are software bundles] * .larger[when executed become containers] * .large[
Images are made of layers] * .larger[each layer encapsulates a set of filesystem changes] * .larger[layers are akin to software deployment steps] * .large[
Layers are **unmutable**] * .larger[except for a R/W layer that is added on top by the container runtime] * .large[
Layers are described in the `Dockerfile`] * .larger[The `Dockerfile` establishes the instructions to create an image] * .larger[The `Dockerfile` is some sort of recipe] ] ] --- # Building an image: docker/whalesay ## 1 The `Dockerfile` .boxed-content[ ```Dockerfile # Containers are generally bootstrapped from an existing OS image # Alpine Linux is a Linux distribution very small and simple # It's special in that it is not based on the GNU Core Utilities FROM alpine # Our container will need perl RUN apk add --no-cache perl # Copy the original 'cowsay' program into one layer COPY cowsay /usr/local/bin/cowsay # Ensure permissions RUN chmod a+rx /usr/local/bin/cowsay # Copy the replacement of the cow asciiart with a whale COPY docker.cow /usr/local/share/cows/default.cow # Instruct the runtime to execute the new program ENTRYPOINT ["/usr/local/bin/cowsay"] ``` ] --- # Building an image: docker/whalesay ## 2 The `cowsay` script .boxed-content[ Because it is a very long perl script, we just download it: ```bash $ curl https://raw.githubusercontent.com/docker/whalesay/master/cowsay -o cowsay ``` ] --- # Building an image: docker/whalesay ## 3 The replacement for the cow (`docker.cow`) .boxed-content[ ``` Perl ## ## Docker Cow ## $the_cow = <
] --- # Docker images and the *Docker Hub* .boxed-content.pad-top[ .no-bullet[ * .large[Images can be distributed through **registries**.] * .larger[*Docker*'s official registry is called *Docker Hub*] * .larger[Thanks to *Docker Hub* we could fetch and execute the `hello-world` image] * .larger[Website: [hub.docker.com](https://hub.docker.com/)] * .large[Let's download two interesting images:] * .larger[*MRIQC*] ``` Bash docker pull nipreps/mriqc:latest ``` * .larger[*fMRIPrep*] ``` Bash docker pull nipreps/fmriprep:24.1.0rc0 ``` ] ] --- # Fetching images & the R/W runtime layer .boxed-content.pad-top[
] --- # Docker is not generally available at HPC systems .boxed-content.pad-top[
] --- # Pulling *MRIQC*'s image on the cluster .boxed-content.pad-top[
] ---
.boxed-content[ .large.center[ # Exercise ] .large.center.gray-text[Pull **docker://nipreps/fmriprep:24.1.0rc0** on the cluster] ]