Docker

Docker is a platform for developing, shipping and running applications by putting them into so called “containers”. Docker seperates the applications from the main infrastructure. Virtual Machine can be thought of as a heavier version of Docker since it utilizes more resources than Docker. In a virtual machine, the entire computer machine is copied digitally. To learn more about what docker is, I highly recommend watching this short Youtube video - Fireship

Why is Docker useful?

Docker enhances the portability of our projects, applications, or scripts. This means that the development version of an app will run consistently on any machine, as long as Docker is supported on that machine. The common internet meme “the code works on my machine” becomes obsolete with Docker, as it ensures that code behaves the same across different environments.

Terminology for learning docker

  1. Dockerfile : an instruction file that builds the Docker images. (base image, dependencies, commands, etc.)

  2. container : an instance of an image. Containers are isolated from one another and from the host system. They do share the host operating system’s kernel (unlike virtual machiens)

  3. image : blueprint of a container a package that results from Dockerfile. Image has different layers and each layer is cached to optimize building process.

  4. docker-compose.yml : useful in running more than one container. docker-compose can be used to run multiple containers simultaneously with one command and handles networking, volumes, port-forwarding, etc.

  • ADD Add local or remote files and directories.
  • ARG Use build-time variables.
  • CMD Specify default commands.
  • COPY Copy files and directories.
  • ENTRYPOINT Specify default executable.
  • ENV Set environment variables.
  • EXPOSE Describe which ports your application is listening on.
  • FROM Create a new build stage from a base image.
  • HEALTHCHECK Check a container’s health on startup.
  • LABEL Add metadata to an image.
  • MAINTAINER Specify the author of an image.
  • ONBUILD Specify instructions for when the image is used in a build.
  • RUN Execute build commands.
  • SHELL Set the default shell of an image.
  • STOPSIGNAL Specify the system call signal for exiting a container.
  • USER Set user and group ID.
  • VOLUME Create volume mounts.
  • WORKDIR Change working directory.