Following the Docker Curriculum guide and various YouTube vids.

What’s a Container?

Learned what a Container is.

What’s Docker ?

What Docker does.

The Docker Daemon is the background service running on the host, in most cases your machine, that manages building, running and distributing Docker containers. The daemon runs on the host OS, and is what the Docker clients talk to. Docker Client , often a CL tool, that allows us to interact with Docker, the daemon to exact. There are various clients including the default Docker Desktop client for Windows.

Dockerfiles and Images

Images

Think of DockerImages like the schematics for your container, they contain all the information needed to set up the container and for your app to run within it. Images have tags that are used to specify the version (but can be named anything really) and the default is “latest”.

Types

  • Base images have no parent image, usually images with an OS like ubuntu, busybox or debian.
  • Child imagesthese are built on top of base images and add additional functionality and features.
  • Official images are images that are officially maintained and supported by Docker themselves. These are typically one word long. Examples include the python, ubuntu, busybox and hello-world images as found on Docker Hub.
  • User images are created and shared by users, and are also built on Base Images. Typically, these are formatted as user/image-name.

Dockerfiles

Whereas, DockerFiles are the files that outline the specific commands needed to produce the Docker Image, since these commands are declared, this allows for reproducibility and portability. A Dockerfile that’s unchanged, will always produce the same Docker Image. Check out Writing a Dockerfile.

Docker Hub

An online repository of Docker images to pull from and push to. Users can share useful and neat images for others to use. Check out.

Modes

Detached mode lets a container run detached from the terminal instance that was used to spin it up, so when that terminal is closed the container continues running. Use the -d option with the run command to flag a container as detached.

Docker Commands

All the commands can be invoked with the flag --help for more info on them such as options and outputs.

  • Running a docker container using docker run imageName. It runs a container using the provided image name. more Running the run command with the -it flags attaches us to an interactive “TTY” in the container. The --rm option flags a container for automatic deletion upon exiting. Very useful.
  • docker images : shows all the images stored on your machine.
  • docker ps : shows all running containers on your machine. Use the -a option flag for more more information.
  • exit is used to exit from an interactive TTY container, like if you had a UNIX system running in a container.
  • docker rm containerID : deletes that specific container. Good for cleanup. Can delete multiple by passing multiple IDs separated by space. To delete all containers that have exited (completed) use: docker rm $(docker ps -a -q -f status=exited)
  • Stopping a container use docker stop containerID