Main ideas and docker file commands (based on this blog post).
FROM ubuntu:18.04
: build image upon ubuntu base imageLABEL maintainer="Firstname Lastname email
: optioal metadataENV LANG=C.UTF-8 LC_ALL=C.UTF-8
: Environment variablesRUN apt-get update && apt-get install -y python-pip
: shell commands to runEXPOSE 7745
: open a port (e.g. for jupyter). Publises only if used -p
or -P
with run
VOLUME /ds
:WORKDIR /ds
: starting point for relative file referencesCOPY hom* /mydir/
: copies new files and add them to the container's filesystem at a destination pathCMD ['/bin/bash']
:CMD
will be executeddocker build -t tutorial -f ./Dockerfile.gpu ./
(This builds an image not a container)
-t tutorial
: name or tag-f ./Dockerfile.gpu
: Dockerfile location./
: context host directory, the relative path refrence pointdocker run -it --name container1 --net=host -v ~/docker_files/:/ds tutorial
-it
: interactive run--net=host
: bind ports to host-v /docker_files/:/ds
: Mount host directory to you as a volume : the mount detinationtutorial
: image nameOpen a terminal iteractively in the container1
container.
docker exec -it container1 bash
Save current state of container as new image (username is e.g. for DockerHub)
docker commit container1 username/image2name:tagname
List running containers
docker ps -a -f status=running
List images
docker images
Push image to registry
docker push username/image2name:tagname