Go here to install Docker, following
the instructions for your particular operating system.
If you don’t have a Docker account create an
account when prompted, or go
here.
After you install Docker, start up Docker
desktop by double clicking on the app. It may take some time to start
up.
Download the files for this activity clicking
here: https://github.com/fhdsl/containers-for-scientists-sandbox/archive/refs/heads/main.zip
Put this file on your desktop so it is easily
findable.
Double click the zip file (or right click and
choose “unzip” or “decompress” to unzip the file.
This activity is built so that you will encounter errors that this guide will work you through! Most common container stumbling block is understanding the idea that containers are isolated from your computer
Which means: If your computer has files, software, or anything else. Your container by default does NOT have it unless you do something to get those files and software on there.
We will encounter both an error of when we don’t have a file we need AND an error of when we don’t have a software package we need. We will guide you through what to do when these expected errors occur.
We need to get the Docker image we want to use. We do this by “pulling” it.
Run this command in your Terminal or Command Prompt window:
docker pull cansav09/practice-image:1
To see what images we have we can run
docker image ls
.
We should see
cansav09/practice-image:1
show up in the output.
Now if want to launch the image for use, we
can use docker run
to turn it into a
container.
docker run cansav09/practice-image:1
To see what containers we have running we have we can run:
docker ps
To run stuff interactively from the command line we can do:
docker exec -it <PUT_CONTAINER_ID_HERE> bash
To run a script using the docker container we could just add reference to a script at the end:
docker exec -it <PUT_CONTAINER_ID_HERE> bash run_analysis.sh
BUT! You will find that this command won’t work yet though, why?
bash: run_analysis.sh: No such file or directory
Question: Does our container have all of the same files that our computer has?
This won’t work because the file run_analysis.sh
is not
a file that our container has. Docker containers do not have all the
files that our computer does; they only have the files we add to it.
Our container is separate from our computer so if we want to use a file we have to attach it using a “volume”.
Let’s point a volume to our workshop files so we have them on our container.
Now we can run:
docker run -v $pwd:/home cansav09/practice-image:1
If you have a windows machine you may have to run this variant
instead. This version has a different ${}
around the
pwd
part.
docker run -v ${pwd}:/home cansav09/practice-image:1
Now we can run the following command but we
will have to run docker ps
and get the container ID we need
to put here.
docker exec -it <REPLACE_WITH_CONTAINER_ID> bash /home/run_analysis.sh
Now we have a new error! What does this mean?
Question: Does our container have all of the same software that our computer has?
Go here to install Podman, following
the instructions for your particular operating system.
Open up your command
line.
Start up Podman by running the following:
podman machine init
podman machine start
Download the files for this activity clicking
here: https://github.com/fhdsl/containers-for-scientists-sandbox/archive/refs/heads/main.zip
Put this file on your desktop so it is easily
findable.
Double click the zip file (or right click and
choose “unzip” or “decompress” to unzip the file.
This activity is built so that you will encounter errors that this guide will work you through! Most common container stumbling block is understanding the idea that containers are isolated from your computer
Which means: If your computer has files, software, or anything else. Your container by default does NOT have it unless you do something to get those files and software on there.
We will encounter both an error of when we don’t have a file we need AND an error of when we don’t have a software package we need. We will guide you through what to do when these expected errors occur.
We need to get the Docker image we want to use. We do this by “pulling” it.
Run this command in your Terminal or Command Prompt window:
podman pull cansav09/practice-image:1
To see what images we have we can run
podman image ls
.
You should see
cansav09/practice-image:1
show up in the output.
Now if want to launch the image for use, we
can use podman run
to turn it into a
container.
podman run cansav09/practice-image:1
To see what containers we have running we have we can run:
podman ps
To run stuff interactively from the command line we can do:
podman exec -it <PUT_CONTAINER_ID_HERE> bash
To run a script using the docker container we could just add reference to a script at the end:
podman exec -it <PUT_CONTAINER_ID_HERE> bash run_analysis.sh
BUT! You will find that this command won’t work yet though, why?
This won’t work because the file run_analysis.sh
is not
a file that our container has. Docker containers do not have all the
files that our computer does; they only have the files we add to it.
bash: run_analysis.sh: No such file or directory
Our container is separate from our computer so if we want to use a file we have to attach it using a “volume”.
Let’s point a volume to our workshop files so we have them on our container.
We will specify a particular file path on our computer or give it
$pwd
Then we can give a :
and a file path we’d
like this to be stored on on the container. Otherwise it will be stored
at the absolute top of the container.
Now we can run:
podman run -v $pwd:/home cansav09/practice-image:1
If you have a windows machine you may have to run this variant
instead. This version has a different ${}
around the
pwd
part.
podman run -v ${pwd}:/home cansav09/practice-image:1
Now we can run:
podman exec -it <REPLACE_WITH_CONTAINER_ID> bash /home/run_analysis.sh
Now we have a new error! What does this mean?
Question: Does our container have all of the same software that our computer has?