WIP ARTICLE
Up until now, Docker has always been a mystery to me. Mostly because I never took time to dive into it. For the past year, I was lucky enough to have David Gageot as my manager at Doctolib. As far as I know, he was one of the early contributors to it, and remains to this day one of the main contributors. Docker has no secrets for him. Here is a video starring David himself, a year after Docker was released to the public:
During his time at Doctolib, I learned quite a lot. And I kept feeding my interest for Docker even after he left. Therefore this article serves as my personal cheatseet for Docker. It is a collection of basic knownledge and advanced tricks.
- Docker images can run nested Docker images (not advisable for production)
FROM <image name>: sets the base image for our Docker imageWORKDIR /home/yolocreates the/home/yolodirectoryCMDvsRUN:RUNis a build step, it creates a layer in the docker image and is therefore cached.CMDis the command to execute when runnning a docker image. If the command outputs something in stdin, it can be reused by other Docker images (see below).ADD . /home/yolocopy the output of the base image (through stdin) to/home/app. If the base image (FROM xxx) output assets as a result of itsCMDcommand, the files will end up in/home/yolo.- What's the difference between the docker commands: run, build, and create
-
Basic common commands:
docker build -t toto .: builds an image from the Dockerfile in the current folder and labels it "toto"docker run --init --rm -ti toto bash: starts a new container from the image labeled "toto" and opens a shell in it