Docker
Also see docker cheatsheet.
- written in Go
- client-server architecture
dockeris the client,dockerd(daemon) is the server
Images
- An image is a private file system just for your container, which provides all the needed files and code
- filesystem, app dependencies, configuration (e.g. environment variables, metadata), scripts, binaries.
- Images are often based on other images
- A Dockerfile describes the steps to create an image, where each instruction creates a "layer" in the image
- Speed: if you change an instruction, only the affected layer is updated!
- Images are stored in docker registries
docker pulldocker push
Container
- Sandboxed process isolated from other OS processes
- uses kernel namespaces and cgroups
- Runnable instance of an image
- Relatively isolated from other containers and host machine by default, but this is configurable.
- Filesystem: a container gets its own "scratch space", but updates won't be seen in other containers even if they are using the same image.
What happens when you run docker run -i -t ubuntu /bin/bash?
- Pulls ubuntu image from configured docker registry unless it's already available locally
- i.e.
docker pull ubuntu
- i.e.
- Creates a new container for running the image
- i.e.
docker container create
- i.e.
- Allocates read-write (local) filesystem
- Creates a default network interface, incl. assigning an IP to the container
- By default, docker containers can use the host machine's network to connect to external networks
- After the container is started,
/bin/bashis executed -tstarts a container-istarts an interactive session where you can input in the terminal and the output gets back