Docker Juice

1) Images

with aufs driver, images are stored under /var/lib/docker/aufs/diff

list :

docker images

delete :

docker rmi 123456abcdef

delete all images :

docker rmi $(docker images -q)

There are two ways to create a Docker image:

• Via the docker commit command

• Via the docker build command with a Dockerfile

Dockerfile syntax (Reference : https://docs.docker.com/engine/reference/builder/ )

  • RUN instruction will execute any commands in a new layer on top of the current image and commit the results.

  • CMD is to provide defaults for an executing container.

  • ENTRYPOINT to set fairly stable default commands and arguments and then use either form of CMD to set additional defaults that are more likely to be changed.

  • ADD instruction copies new files, directories or remote file URLs from <src> and adds them to the filesystem of the container at the path <dest>.

  • COPY instruction copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.

  • EXPOSE opens a port for linked containers.

  • FROM base image to use for the build.

  • USER sets the default user within the container.

  • VOLUME creates a shared volume that can be shared among containers or by the host machine.

  • WORKDIR sets the default working dir for the container.

  • ENV sets an environnement variable in the container.

2) containers

/var/lib/docker/containers

list :

docker ps

docker ps -a

delete all containers :

docker rm $(docker ps -a -q)

Docker Python

docker run -it --rm --name my-lovely-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:3 python thisScript.py