Kernel
Applications
Hardware
Docker (fast)
Virtual Machines (slow)
1. Create a DockerHub account (hub.docker.com)
2. Docker Desktop for Mac
Docker Desktop for Windows
Docker for Linux
you can have many running containers of an image
$ docker pull hello-world
in your terminal
$ docker run hello-world
in your terminal
$ docker run -it ubuntu bash
in your terminal
give us an interactive terminal
name of image
commandto run
$ docker run ubuntu echo 'hello world'
in your terminal
name of image
commandto run
inputs
$ docker ps
in your terminal
Shows your currently running containers
$ docker ps -a
in your terminal
Shows your currently running and stopped containers
$ docker start -i <container_name>
to restart (interactively) a stopped container
$ docker stop <container_id/name>
in your terminal
Stops a running container
$ docker rm <container_id/name>
to remove a stopped container
$ docker images
in your terminal
Shows the images stored on your computer.
Pay attention to size!
$ docker rmi <image_id>
in your terminal
removes an image
$ docker pull <image_name>
$ docker run -it <image_name> <commands> <args>
$ docker ps -a
$ docker images
$ docker stop/rm <container_name/id>
$ docker rmi <image_name/id>
$ docker run -it --rm <image_name> <commands> <args>
when the container stops, automatically delete it
$ mkdir myProject
in your terminal, create a new folder
create a file named Dockerfile in that folder and open it with a text editor
FROM python:3.6
RUN pip install jupyterlab
in your text editor
$ docker build -t <image_name> .
in your terminal, in your folder
$ docker build -t my_image .
in your terminal, in your folder
$ docker run -p 8888:8888 -ti --rm my_image jupyter lab --ip 0.0.0.0 --port=8888 --allow-root
then go http://127.0.0.1:8888/lab in your web browser
in your terminal, in your folder
$ docker run -p 8888:8888 -ti --rm -v $PWD:/myworkspace
-w /myworkspace my_image:latest jupyter lab --ip 0.0.0.0 --port=8888 --allow-root
-v mounts a directory from you local computer to a location in the container
-w sets the working directory
$ pip install dipy
Hint: normally we'd do:
In your Dockerfile
FROM python:3.6
RUN pip install jupyterlab
RUN pip install dipy
ADD ./myscript.py /myscript.py
ENTRYPOINT ["python", "/myscript.py"]
print('hello human')
Create a file called myscript.py
$ docker login
$ docker build -t <username>/<image_name>:<version> .
$ docker push <username>/<image_name>:<version>
https://github.com/kaczmarj/neurodocker
generates Docker and Singularity images!