Skip to content

Docker Notes

Image vs Container

  • image = base “box”
  • container = “writeable / instance” of an image

Image vs Container (SO)

Docker Terminology 1

  • Docker Containers: Small user-level virtualization (isolation) that helps you install, build and run your code/workflow. All the code would be continuosly running in these containers.
  • Docker Images: An image is an inert, immutable, file that’s essentially a snapshot of a container. These are your actual committed containers (ones that have the process running, data stored, ports exposed to be used). Docker images are essentially the stored instances that you can (actually move around).
  • Dockerfile: It is a YAML (almost) based file from which Docker creates an image. It can be thought of as an automated script that has all the steps you want to execute.

Dockerfile 2

  • A Dockerfile contains the info for the container. "A Dockerfile is where you write the instructions to build a Docker image."
  • This Dockerfile is used to build the image. "Once you’ve got your Dockerfile set up, you can use the docker build command to build an image from it."

Volumes are the “data” part of a container, initialized when a container is created. Volumes allow you to persist and share a container’s data. Data volumes are separate from the default Union File System and exist as normal directories and files on the host filesystem. So, even if you destroy, update, or rebuild your container, the data volumes will remain untouched. When you want to update a volume, you make changes to it directly. (As an added bonus, data volumes can be shared and reused among multiple containers, which is pretty neat.)

Creating a container is Docker is done with the run command followed by, amongst other things, a command to run within the container. There can be only one CMD command. It’s the philosophy of docker — one process per container.

Pollution: Uwanted Images & Containers

  • Everytime a container is spun up and then exited, it remains in the list of containers, but in an "Exited" state.
  • To remove unwanted containers, run 'docker rm [container-id]' 3
  • To get the container-id run docker ps -a and the list starts with each container's id.