Docker Journey - Let's Start!
Docker Journey
Let’s take some time to explore and personally experiment with Docker and container technology! This article is the “Intro” and the “Table of Contents” to some “Short and To The Point” Docker related guides. They’re meant to serve both as a starting point to learning Docker, and as a guide into a more deep understanding of Docker and container technology. I hope you enjoy using and learning about Docker as much as I do.
Docker is REALLY cool!!
Docker and container technology are two if the main reasons I love DevOps so much!
I find so much joy spinning up Docker containers for temporary services like testing my app, maybe a quick and dirty DB front-end or a File Downloader, and of course some persistent ones such as having my own DropBox alternative locally, my own File Server to backup and share my files, Web Servers hosting my blog(s) and other documentation sites, playing around with different OSes, and running misc apps and web-apps, either by my own createion or from GitHub and other open source repos and forums.
All of this without installing anything on my machine other than Docker because, once I stop and remove the container, it’s like it never happened.
Docker is a great tool for countless of usecases.
So what is it really?
Docker is a platform that helps you easily create, deploy, and run applications in lightweight, portable containers. Think of a container as a small, self-contained environment (computer/server) that includes everything an application needs to run, like code, system tools, libraries, and settings. This makes sure the application works consistently, regardless of where it’s running—whether it’s on your laptop, in a data center, or in the cloud.
The short version: When you run a Docker container, it shares the host operating system’s kernel but operates in isolation from other containers, ensuring consistent performance and behavior regardless of the environment.
How does Docker differ from a virtual machine??
When you run a Virtual Machine (VM), it emulates an entire physical computer, including its own operating system, on a host system. Each VM includes a full copy of an operating system, along with virtualized hardware resources such as CPU, memory, and storage. This allows multiple VMs to run on a single physical machine, each operating independently with its own isolated environment. However, because VMs include entire operating systems, they are typically larger and require more resources than containers.
Where do we start??
First, we install docker, then we start fidgeting around understanding some concepts. Once we get the hang of things, we can start using Docker self hosting our own apps or other open source ones, inside container. Docker can run on a single host (like we’ll run it in our tutorials), but can also be used in ‘Swarm’ mode which means multiple Docker hosts orchestrating containers between themselves as needed.
Basic Concepts
Some basic concepets about container technology:
-
Docker Daemon: The Docker daemon is a background service running on the host operating system. Kinda like a helper that is waiting for docker related commands. It listens for Docker API requests and handles tasks such as building, running, and distributing Docker containers.
-
Docker cli: The Docker Command Line Interface (CLI) is a tool that allows users to interact with the Docker daemon through commands typed in the terminal. With the Docker CLI, users can perform tasks such as building images, running containers, managing networks, and more.
-
Docker Network(s): When installed Docker adds a few default networks, and WE are encourageed to create our own to use with our projects.
Docker networks allow containers to communicate with each other and with the outside world. They can be used to define how containers are connected, isolated, and how they can access external networks. Different network types like bridge, host, and overlay provide various levels of control and connectivity. -
Docker Image(s): Docker images are the what containers are made from. They’re lightweight, standalone, and executable software packages that include everything needed to run a piece of software, such as code, runtime, libraries, and settings. Images are used as blueprints to create Docker containers. We can build our own imgaes or use premade images from the Docker Hub or from countless other image registries.
-
Docker Container(s): Docker containers are runtime instances of Docker images. They include the application and all its dependencies, running in an isolated environment using the host’s operating system kernel but separated from other containers to ensure consistent performance.
(Wait but that sounds just like images!
Correct, however… a container is a RUNNING instance of an image.
It’s BASED on an image, but it’s not the actual image.) -
Docker Volume(s) and Folder Bindings: Containers are ephemeral, this means that when you delete one, all its data is removed as well. To mitigate this, we have Volumes and Folder Bindings.
Docker volumes are used to persist data generated by and used by Docker containers. They are independent of the container lifecycle, ensuring data is not lost when containers are removed. Folder bindings allow you to map directories on the host system to directories within a container, providing another way to manage data persistence and access. -
Docker cli vs Docker Compose: Some projects require many containers and complex configurations, making management challenging with individual Docker CLI commands. Docker Compose simplifies this by allowing you to define and manage multi-container applications using a single YAML file. This file specifies all the services, networks, and volumes your application needs, enabling you to start, stop, and configure everything with a single command.
Diagram
+-------------------------+
| Docker Host (PC/Server) |
+-------------------------+
|
|
v
+----------------------+
| Docker Daemon |
+----------------------+
|
+-----------------------+------------------------+
| | |
v v v
+--------------------+ +--------------------+ +--------------------+
| | | | | |
| +--------------+ | | +--------------+ | | +--------------+ |
| | Docker | | | | Docker | | | | Docker | |
| | Container | | | | Container | | | | Container | |
| +--------------+ | | +--------------+ | | +--------------+ |
| | | | | |
+--------------------+ +--------------------+ +--------------------+
Docker Journey - If Anything START HERE!
I’ve aggrigated some posts I’ve published and if read by a certain order, you can certainly learn the ropes and start using containers like a BOSS!
Here are the links in the recommended order:
-
Install Docker: Link
This article quickly goes over the steps to isntall Docker on a Linux based system. (You can checkout the official documentation if you want to use Windows or MacOS instead) -
Basic Docker Command: Link Understanding some Docker basic commands.
-
Let’s Play With Docker: Link Here is where we start running containers, volumes and folder bindings.
-
Deploy a Nextcloud Stack (docker-compose): Link
After learning about docker networks, volumes, containers and images, we’ll finally create our own USABLE DropBox replacement service call Nextcloud. It’s open source, and I’ve been using it for over a decade and love it!