Docker 101

Part of a (short) series on 'knowing enough to be dangerous' with Docker.

In this YouTube video titled “Docker 101,” John provides an introduction to Docker and its importance in simplifying the deployment process. They explain the concept of Docker containers, which are loosely isolated environments that contain all the necessary requirements for an application to run. John demonstrates how to build and run containers using Docker, using Python as an example. They also discuss the use of Docker Hub, a repository for Docker images, and explain the concept of Dockerfiles, which are recipes for creating Docker images. John then covers topics like exposing ports, running multiple containers using Docker Compose, and the option of uploading images to Docker Hub for sharing.

00:00:00 In this section, John is introducing himself and explaining the requirements for following along with the presentation. He also provides an overview of the topics that will be covered, including why Docker is important, example workflows, and the basics of Docker containers. John emphasizes the ability of Docker to isolate applications and simplify the deployment process. He also mentions that he will be discussing building custom Docker images and Dockerfile basics in later parts of the presentation. The section concludes with John sharing examples of traditional workflows and explaining how Docker can simplify the process by isolating dependencies.

00:05:00 In this section, John discusses the challenges of software distribution and the concept of dependency hell, where different libraries and systems have varying dependencies, leading to a nightmarish experience. John mentions workarounds like using virtual machines or packaging applications with their libraries. However, Docker provides a simpler solution by removing the need for host configuration and runtime requirements, without requiring a heavyweight virtual machine. Docker creates a Loosely isolated environment called a container, which contains all the necessary requirements for an application to run, making software distribution much easier and efficient.

00:10:00 In this section, the concept of containers is introduced. Containers are described as loosely isolated environments that are similar to virtual machines but much lighter. While virtual machines isolate every aspect of the hardware they are running on, containers only care about the necessary functionalities like network connections. Containers aim to keep instances isolated from the host environment to avoid interference. They are based on read-only templates called images, which serve as the initial state of a container. Images are built on top of one another, with the top layer usually representing the application. It is recommended to keep the stack of layers as short as possible to maintain a lightweight image. The difference between traditional virtual machines and containerized architectures is also explained, highlighting the shorter stack and minimal extras in containers. The goal is always to make containers thinner, with only the necessary components included.

00:15:00 In this section, John introduces the “play along at home” portion of the tutorial where they will demonstrate building web-based containers using Python. They mention that Python knowledge is not required as the necessary files have already been provided. John also suggests using other languages such as Perl or PHP if preferred. They explain that they will be building a container in Alpine Linux and highlight its small size, making it ideal for demos. John demonstrates running Alpine Linux in Docker and explains that they are operating as root since there are no users included in the image. They also mention that the Alpine Linux image is approximately 7MB in size. John asks for confirmation from the audience if they have successfully set up Docker and invites questions or comments. They explain the concept of the unique hash associated with each layer and that Docker builds containers by stacking these layers in order. They clarify that an internet connection is required to download the necessary Docker images.

00:20:00 In this section, John discusses the need to eliminate unnecessary Docker images in order to avoid storage issues. They explain how Docker maintains a cache of images, which can accumulate over time if not deleted. John also provides a demonstration of how to clean up Docker images. Additionally, John explains that Alpine Linux, which is used in Docker, is a minimal operating system that runs very few processes and requires less memory compared to other operating systems like Ubuntu. John also mentions the ability to configure Docker to utilize specific resources, such as a limited number of cores. Lastly, there is a brief discussion about running Docker on Windows and the recommendation to use CMD for Windows users.

00:25:00 In this section, John explains how to check if you are inside the Alpine Linux container and how to access your running containers. They mention that if you see the slash hash prompt, then you are inside Alpine. They also explain that the Docker PS command is equivalent to the PS command for Linux and it displays the running containers. John demonstrates how to exit the container and return to the host. They also mention that ending the container’s operation does not remove it, and you can use Docker PS -a to see both running and non-running containers. Finally, they discuss how to remove containers and images, and suggest using Docker system prune to clean up.

00:30:00 In this section of the video, John demonstrates how to manually remove a Docker container by using the Docker RM command followed by either the container ID or name. It is important to note that this command only removes the running instance of the container, not the container image itself. John also mentions the use of the Docker prune command to remove multiple containers at once. They advise using the “–RM” flag when running a container if it is meant to be temporary and should be deleted once it is stopped. John recommends being cautious when using the RM flag and suggests not relying on it for important tasks. They then move on to discussing how to run Python in a Docker container using different image variants and tags.

00:35:00 In this section of the video, John introduces Docker Hub, a repository for Docker images. They explain that by visiting and navigating to the Python section, users can find various Python versions available for use. John notes that there are simple tags and variations of Python available, including different versions for different operating systems like Debian and Ubuntu. They mention that these images on Docker Hub are safe to use, as they are official Docker images. John also discusses the concept of Dockerfiles, which are recipes for creating Docker images. They explain that Dockerfiles contain a series of steps that configure the final image. John goes through a sample Dockerfile, explaining each directive and the order in which they are executed. They mention that the Dockerfile specifies the base image (in this case, Ubuntu) and sets the working directory. John concludes by emphasizing that Dockerfiles are used for the static parts of a container and not for runtime requirements.

00:40:00 In this section, John explains the use of the “copy” and “expose” directives in a Dockerfile. The “copy” directive is used to copy files from the host to the image, and it can be used to copy between different containers as well. The “expose” directive is used to specify which ports the image will listen on when it is run as a container. John also mentions that the “expose” directive is often used by management interfaces to determine the ports on which the container is running.

00:45:00 In this section of the video, John discusses various aspects of Docker, including exposing ports and running containers. They explain that when running a container, it is important to specify the correct ports so that communication is possible. They also mention that the “work directory” can be customized, allowing the user to switch between different directories as needed. John emphasizes the recommended way of creating commands in Docker, which involves using arrays or lists. They demonstrate how to build a container using the Docker build command and explain the significance of the dot (.) in the command, which indicates that the build should occur in the current folder. John also highlights the importance of the order in which dependencies are specified in the Docker file, as it can significantly impact the build time. They mention that if one of the dependencies is large, it is best to include it early in the file to optimize the build process. Towards the end, John explains how to run a container and open the necessary ports to access a web interface. They provide instructions on connecting to the container using a web browser and show a simple Python web page that can be accessed. Finally, they mention that in the next part of the video, they will discuss accessing host files and transferring files to and from the container during runtime.

00:50:00 In this section, John discusses Docker compose and how it can be used to run multiple containers simultaneously, which is the first step in container orchestration. They mention examples such as running a MySQL server, PHP MySQL admin, and a web interface together. John also mentions the option of uploading images to Docker Hub for sharing, or sharing it through Source by having it on GitHub. They briefly mention the possibility of doing multi-arch images in part four and hint at discussing cloud deployment in part three. John wraps up by acknowledging that the access log is almost complete and invites any questions from the audience.

Summary text originally from with light post editing.