Mac, Windows and Linux • Multi Architecture (intel, armv5-8, ppc, i386) • Split into many components • Component standardisation (OCI, CNCF) • Adopted by a large majority of cloud providers
application run • Contain everything needed to run the application (libs, binaries, etc.) • Own its dedicated network stack, users, process, etc. • Share the host kernel • Could have some resource restriction (CPU, Ram, etc.)
set during build Working directory Copy files into image Command executed during build Copy folder into image Default command that will be executed during a docker run
build -t myapp:v1.0.0 --build-arg NODE_ENV=development . Command to build an image Give a name and tag to the image Set a build variable Build context If the Dockerfile file has another name or is located elsewhere, it must be specified with: -f .docker/Dockerfile Warning : the context build is always the last parameter
app from my browser - Ctr+C do not stop my app - The container name will be randomly generated - ex: goofy_kapitsa ❯ docker run myapp:v1.0.0 Command to run a container Image name and tag
8080:80 --name myapp myapp:v1.0.0 Run container in background ❯ docker run –ti –p 8080:80 --name myapp --rm myapp:v1.0.0 bash Automatically remove the container when stopped Change the default command (CMD)
--rm -v `pwd`/mydir:/data ubuntu Command for using a volume Local directory on host Directory in the container Be careful when mounting a file! Changes to file may not be reflected in container Ex: sed, vim, VS Code
Reproduce production network topology • Container can communicate with each other using by name, id or alias • Many network type/driver available: • Bridge (default) • Internal • None • Host
run --network intnet curlimages/curl -m3 https://google.com ╰─❯ curl: (28) Resolving timed out after 3002 milliseconds Command to manage networks Network type Network name Attach the container to the intent network
docker run -d --network mynet --name nginx --network-alias web nginx ❯ docker run --rm --network mynet curlimages/curl -m3 http://web Use a specific network driver Adds an alias to the container in networks it is connected Container name or ID also works
name on the network Container image If the container crash, docker will restart it List of volumes to attach to the container List of environment variables List of networks to attach to the container
You can attach a volume to a directory in another volume Definition for building the image Create a dependency on another service List of port to link to the host
-a List the containers created by compose Including those stopped ❯ docker compose logs -f [name of service(s)] Show logs And show new logs as they come ❯ docker compose up –d [name of service(s)] Command for compose Start service(s) In background
Docker to a registry Pull an image locally Push a local image to a registry ❯ docker push jmaitrehenry/myimage ❯ docker pull kumojin.azurecr.io/myapp/api:v1.0.0 Connect to a specific registry