Last week I delivered a Docker workshop. I assembled A list of useful links for the students to help them review the course.
To understand how the Docker piece integrated into the programming architecture puzzle, we have to start with Interface Oriented Programming. One of the reasons that Object-oriented programming did not fulfill its promise was the inherent coupling between its components. Abstracting the interconnection between the application components by using interfaces enables a complete decoupling between the moving parts of the program. The main benefit of this decupling is that now the developers can make changes and bug fixes to any component implementation without affecting the rest of the program, As long as the interface stays the same.
Another benefit of the decupling is giving the developer the freedom to choose different technologies and frameworks for any component. Actually, without interfaces, we could not do microservices architecture. The whole idea of microservices architecture is to split the program into a collection of autonomous services with a specific purpose and a well-defined interface.
Docker is one of the technologies used to build a microservice. The idea behind Docker is to pack each microservice together with all its dependencies in a container image. The container image is then run under the docker runtime. The Docker runtime is a software hypervisor that runs above the operating system and isolates the running containers from each other. For additional information about the benefits of containers, the difference between a container and a virtual machine, a comparison of the docker runtime and hardware-based hypervisor, and other related information, go to https://www.docker.com/resources/what-container. To make a long story short, good enough isolation, fast startup, smaller images.
The entry point to all the information about Docket is https://www.docker.com/. Sign up to the Docker Hub at https://hub.docker.com/signup. Grab a cool Docker ID. it will be your prefix for your docker images repository. The free personal plan https://www.docker.com/products/personal is good enough for all learning purposes and more.
The next step, as recommended in the getting started guide https://www.docker.com/get-started is to download and install the tools. You can’t use Docker without installing the runner first. I warmly recommend the docker-desktop https://www.docker.com/products/docker-desktop, and if you want to play around without installing anything, you can do most of the learning using the Docker playground at https://labs.play-with-docker.com/.
The next step is to learn and practice. The getting started tutorial at https://docs.docker.com/get-started/ is a good starting point. It is short enough, clear, and covers most of the basics. More community training and valuable information are available at https://docs.docker.com/get-started/resources/.
All the documentation of Docker is at https://docs.docker.com/. In the reference section at https://docs.docker.com/reference/, you will find the docker command-line interface (CLI) reference at https://docs.docker.com/engine/reference/commandline/cli/, and the Dockerfile reference for the Docker build command at https://docs.docker.com/engine/reference/builder/.
The principal tool you need to study is the Docker CLI. The “docker –help” command lists all the commands alphabetically, which is not very useful. Below is the list ordered by functionality. You can access the specific command online help at https://docs.docker.com/engine/reference/commandline/docker/
Container related commands
docker ps – List containers
docker run – Run a command in a new container
docker exec – Run a command in a running container
docker stop – Stop one or more running containers
docker start – Start one or more stopped containers
docker restart – Restart one or more containers
docker kill – Kill one or more running containers
docker pause – Pause all processes within one or more containers
docker unpause – Unpause all processes within one or more containers
docker wait – Block until one or more containers stop, then print their exit codes
Additional container related command
docker create – Create a new container
docker rename – Rename a container
docker rm – Remove one or more containers
docker cp – Copy files/folders between a container and the local filesystem
docker export – Export a container’s filesystem as a tar archive
docker import – Import the contents from a tarball to create a filesystem image
docker diff – Inspect changes to files or directories on a container’s filesystem
docker attach – Attach local standard input, output, and error streams to a running container
docker update – Update configuration of one or more containers
Image related commands
docker images – List images
docker build – Build an image from a Dockerfile
docker commit – Create a new image from a container’s changes
docker history – Show the history of an image
docker save – Save one or more images to a tar archive (streamed to STDOUT by default)
docker load – Load an image from a tar archive or STDIN
Repository/Registry related commands
docker login – Log in to a Docker registry
docker logout – Log out from a Docker registry
docker pull – Pull an image or a repository from a registry
docker push – Push an image or a repository to a registry
docker tag – Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
docker search – Search the Docker Hub for images
docker rmi – Remove one or more images
General information commands
docker -v, –version – Print version information and quit
docker version – Show the Docker version information
docker info – Display system-wide information
docker stats – Display a live stream of container(s) resource usage statistics
docker top – Display the running processes of a container
docker events – Get real time events from the server
docker inspect – Return low-level information on Docker objects
docker logs – Fetch the logs of a container
docker port – List port mappings or a specific mapping for the container