Skip to content
Get App

I Wish Someone Explained Docker Like This

A beginner-friendly explanation of Docker: what containers are, how they differ from virtual machines, and the client, daemon, and registry architecture behind it.

Key Takeaways

  • Docker containers offer a lightweight, portable, isolated way to run applications compared to VMs
  • Docker works at the OS level by sharing the host kernel, which is why it uses fewer resources
  • The client-daemon-registry model is central to how Docker pulls, runs, and manages images and containers
  • Docker Compose simplifies running multi-container applications, which is common in self-hosting

What the video covers

  • Docker is a platform for building, deploying, running, and managing applications inside lightweight containers
  • Containers bundle an app with its libraries, dependencies, and configuration, isolated from the rest of the system
  • Containers are portable across Mac, Windows, and Linux as long as Docker runs and the image matches the CPU architecture
  • Containers start quickly and have little performance overhead compared to virtual machines
  • Kubernetes can orchestrate large numbers of containers in enterprise environments
  • Virtual machines run a full guest OS with a hypervisor, making them heavier on memory, storage, and CPU
  • Docker uses OS-level virtualization and shares the host kernel, which keeps it lightweight
  • Docker follows a client-server architecture with a client, a daemon, and a local or online registry
  • Images are pulled from registries such as Docker Hub and run locally as containers
  • The video demonstrates pulling an Ubuntu image, running and attaching to containers, and mapping volumes

Answers

Questions about this video

What is the main difference between a Docker container and a virtual machine?

A virtual machine runs its own full guest operating system on top of a hypervisor, which makes it heavy on resources. A Docker container shares the host operating system's kernel and only packages the app and its dependencies, making it lightweight and fast to start.

What are the three main components of Docker's architecture?

Docker uses a client-server architecture made up of the Docker client, which sends requests, the Docker daemon, which does the work, and a registry, local or online such as Docker Hub, where images are stored and pulled from.

Why is Docker considered portable?

A container bundles the application with everything it needs, so the same container can run on Mac, Windows, or Linux wherever Docker is installed, provided the image matches the machine's CPU architecture. Developers don't need separate builds for each operating system.

Full Transcript — Download SRT & Markdown

00:00
Speaker A
Docker. You've probably heard of this floating around, pun intended. However, you might not know what it actually is.
00:07
Speaker A
If you're into self-hosting, you'll see that you need to use Docker to get things up and running. But, how does it actually work? What is it? And why is Docker so insanely useful? Well, don't worry because I'll explain Docker for
00:20
Speaker A
If you're into self-hosting, you'll see that you need to use Docker to get things up and running. But how does it actually work? What is it? And why is Docker so insanely useful? Well, don't worry, because I'll explain Docker for absolute beginners and provide a brief overview, so even you and your giraffe can understand it. So, what is Docker?
00:27
Speaker A
Well, Docker is a platform that allows people to build, deploy, run, and manage applications via things called containers. Essentially, it's software that allows you to run applications.
00:39
Speaker A
Well, Docker is a platform that allows people to build, deploy, run, and manage applications via things called containers. Essentially, it's software that allows you to run applications.
00:53
Speaker A
this package or container contains the app along with libraries, dependencies, and configurations needed for it to run or function. Okay, so what? Well, this means that, number one, the application is loosely separated or somewhat isolated from the rest of the system,
01:11
Speaker A
Yet, you might be thinking, "So, what? Can't we already do this? And why do we need Docker?" Well, Docker is extremely special because it allows you to package and run an application into a neat little package called a container. Now, this package or container contains the app along with libraries, dependencies, and configurations needed for it to run or function. Okay, so what? Well, this means that, number one, the application is loosely separated or somewhat isolated from the rest of the system, meaning you can easily start, stop, remove, and update applications without it affecting the rest of your system. And Linux uses something called namespaces to isolate these containers and something called cgroups to manage and control how resources are used. It also means that these containers are extremely portable and lightweight. So, you take this container or software bundle and can run it in different environments or even operating systems like Mac, Windows, and, obviously, Linux.
01:28
Speaker A
means that these containers are extremely portable and lightweight. So, you take this container or software bundle and can run it in different environments or even operating systems like Mac, Windows, and obviously Linux.
01:40
Speaker A
Basically, wherever, as long as you are also running the Docker software and the image supports your CPU architecture.
01:47
Speaker A
So, if you're an app developer, you don't have to create a different version for different OSes, just one version that works on all compatible machines.
01:57
Speaker A
So, if you're an app developer, you don't have to create a different version for different OSes, just one version that works on all compatible machines.
02:11
Speaker A
necessary for your use case, and the container starts extremely quickly. And the great thing is that you won't really feel a hit to your performance. Also, deleting containers is also extremely easy and quick, making deployments super fast based on what you'd like to do. And
02:27
Speaker A
However, if you're a Linux user, you'll be happy to know that Docker works best on Linux. Number three, containers are fast. You can easily download an image and spin up a container in no time. You simply need to provide the options necessary for your use case, and the container starts extremely quickly. And the great thing is that you won't really feel a hit to your performance. Also, deleting containers is extremely easy and quick, making deployments super fast based on what you'd like to do. And in more enterprise environments, you can use something called Kubernetes, which allows you to manage or orchestrate all of these containers on a mass scale. So, Docker here is the magic software underneath all of this that allows these containers to function. So, let's get a little bit more technical and understand how Docker really works.
02:43
Speaker A
little bit more technical and understand how Docker really works. So, to understand how Docker actually works, you first need to understand a virtual machine or VM, as this will provide a basic understanding of why Docker was even formed. So, a virtual machine or
02:58
Speaker A
So, to understand how Docker actually works, you first need to understand a virtual machine, or VM, as this will provide a basic understanding of why Docker was even formed. So, a virtual machine, or virtualization, allows you to run a virtual computer or device on top of your existing operating system. This is done by something called a hypervisor. And a hypervisor is just software that manages the resources that are allocated to a virtual machine or machines. But more on that in a little bit. The VM therefore allows you to perform actions on this guest OS without it actually affecting your host system.
03:15
Speaker A
machines. But, more on that in a little bit. The VM therefore allows you to perform actions on this guest OS without it actually affecting your host system.
03:24
Speaker A
For example, if you decide to destroy a virtual machine by running a dangerous command, it again will only affect that virtual system you're running and not anything else. The great thing, therefore, is this isolation, but also being able to run operating systems from another environment. For example, you could run Windows on a Linux PC or vice versa via VMs. Okay, so what's the catch? Well, the problem is that virtual machines have to share resources like CPU cores, memory, and storage with the host operating system. Well, that's kind of like Docker. So, what? Well, not exactly. This is because a virtual machine has to run its own operating system. Remember, it's like a simulation of an actual physical machine running its own kernel, tasks, etc. Therefore, it only runs as well as the resources you can give to it. Anyway, this means much more memory, storage, and CPU usage. Essentially, it's a heavy dude sitting on you. Anyway, anyway, what has all of this got to do with Docker and containers? Well, these two main issues are what Docker fixes. It provides a way to run lightweight and somewhat isolated instances of apps that are extremely portable across multiple OSes. So, Docker is software that runs at the operating system level, or OS level. Now, this is called OS-level virtualization, if you want to impress your girlfriend or boyfriend. Anyway, this means it runs on top of your host operating system and thus shares resources with it. And the main resource it shares is the core of the operating system, known as the kernel. And this is extremely important because it allows Docker to remain lightweight, as you don't need to duplicate an entire OS just to run a single app. So, Docker uses something called client-server architecture, where we have a client, a daemon, and a local or online registry. Now, these are the three main components that make up what we call Docker. So, let's tackle what the Docker client is first. The Docker client is the one who requests things from something called the Docker daemon. Now, the client is typically you using Docker via a command line interface. However, there is a GUI version called Docker Desktop, but in this video, I'll be focusing on the CLI.
03:39
Speaker A
another environment. For example, you could run Windows on a Linux PC or vice versa via VMs. Okay, so what's the catch? Well, the problem is that virtual machines have to share resources like CPU cores, memory, and storage with the
03:53
Speaker A
So, for example, currently I'm using the Docker client to get all of the available Docker images on my system.
04:10
Speaker A
it only runs as good as the resources you can give to it. Anyway, this means much more memory, storage, and CPU usage. Essentially, it's a heavy dude sitting on you. Anyway, anyway, what has all of this got to do with Docker and
04:24
Speaker A
And this client talks to this daemon using something called an API, or application programming interface. It can also use something called a Unix socket. Anyway, an API just means that data is exposed and sent for a specific purpose. And using this API, the client and the daemon can interact or communicate. However, it's important to know that in Docker, the client and daemon don't have to be running on the same system. For example, you can have a client running on one system which communicates with a daemon on another system on the network. They obviously need to be able to communicate with each other, of course. So, I've mentioned daemon a few times, but what the heck actually is it? Well, the Docker daemon is simply a service that runs in the background and listens for API requests from the client. Now, the daemon in Docker is called dockerd, the D here standing for daemon. So, dockerd is like the middleman, which manages a number of different components like images, containers, networks, volumes, and storage, etc. I remember the API thing I mentioned earlier? Well, the Docker daemon will be constantly listening for any Docker API request from, you guessed it, the Docker client. Then we have something called Docker registries. This is where Docker stores and distributes things called images.
04:41
Speaker A
called OS level virtualization, if you want to impress your girlfriend or boyfriend. Anyway, this means it runs on top of your host operating system and thus shares resources with it. And the main resource it shares is the core of
04:54
Speaker A
Now, an image is simply a standard or a sort of package that includes all of the files, libraries, and configurations to actually run a container. And there are two properties of images that you need to remember. So, number one, an image doesn't change. It's immutable. So, once you create an image, you can only add changes on top of it or make a completely new one. And number two, an image is made up of loads of layers.
05:10
Speaker A
we have a client, a daemon, and a local or online registry. Now, these are the three main components that make up what we call Docker. So, let's tackle what the Docker client is first. So, the Docker client is the one who requests
05:24
Speaker A
Now, each layer is a change that can add, remove, or even modify files. And you'll see these layers when you're downloading an image, like I am here.
05:37
Speaker A
So, for example, currently I'm using the Docker client to get all of the available Docker images on my system.
05:43
Speaker A
And also, an image can be built on other images, too. Okay, so where do we find these images? Well, that would be the registry or hub. The most popular and default is Docker Hub. And this is like a hub or source for all of your images.
05:58
Speaker A
purpose. And using this API, the client and the daemon can interact or communicate. However, it's important to know that in Docker, the client and daemon don't have to be running on the same system. For example, you can have a
06:10
Speaker A
You can then download them from the registry so that you can run them locally, or, as it's known in the Docker world, pulling these images. Now, there are all sorts
06:22
Speaker A
actually is it? Well, the Docker daemon is simply a service that runs in the background and listens for API requests from the client. Now, the daemon in Docker is called Docker D, the D here standing for daemon. So, Docker D is
06:35
Speaker A
like the middle man which manages a number of different components like images containers networks volumes and storage, etc. I remember the API thing I mentioned earlier? Well, the Docker daemon will be constantly listening for any Docker API request
06:51
Speaker A
from, you guessed it, the Docker client. Then we have something called Docker registries. This is where Docker stores and distributes something called images.
07:00
Speaker A
Now, an image is simply a standard or a sort of package that includes all of the files, libraries, and configurations to actually run a container. And there are two properties of images that you need to remember. So, number one, an image
07:14
Speaker A
doesn't change. It's immutable. So, once you create an image, you can only add changes on top of it or make a completely new one. And number two, an image is made up of loads of layers.
07:25
Speaker A
Now, each layer is a change that can add, remove, or even modify files. And you'll see these layers when you're downloading an image like I am here.
07:41
Speaker A
And also, an image can be on other images, too. Okay, so where do we find these images? Well, that would be the registry or hub. The most popular and default is Docker Hub. And this is like a hub or source for all of your images.
07:56
Speaker A
You can then download them from the registry so that you can then run them locally, or as it's known in the Docker world, pulling these images. Now, there are all sorts of images on Docker Hub, which you can take a look at here. Okay,
08:08
Speaker A
so now you understand how Docker works on a very basic and fundamental level. So, let's look at the real juicy stuff, and that's containers. So, a container is simply an instance of an image that is actually running on your system. I
08:21
Speaker A
remember the app and all its configurations, dependencies, and so on is bundled into this neat little package called a container. So, that's enough theory talk. Let's get a little more practical. I'll keep things simple initially. So, say I want to run an
08:34
Speaker A
Ubuntu container and interact with it somehow. So, the first thing I'll need to do is download the Ubuntu image from the public registry to my local system, which is running Cashio OS, which is an Arch-based distribution. So, I'll run
08:48
Speaker A
docker pull Ubuntu. Now, it's important to know that Docker uses something called tags. You can see that when I pull this image, it actually has the latest tag over here. This is by default. So, a tag just essentially
09:01
Speaker A
tells Docker what version of the app I want to download. So, for example, if I go to Docker Hub, which is the place to browse these images, and search for the Ubuntu image, I can see the supported tag section. So, for example, if I try
09:15
Speaker A
and download Ubuntu, but with the 26.10 tag, then that version will be downloaded. So, let's do that. All I have to run is docker pull Ubuntu:26.10.
09:25
Speaker A
I remember I need a colon here to tell Docker that I'm using a tag. However, for the rest of the demo, I'll be using the latest Ubuntu image version. Anyway, as you can see, the image successfully downloaded.
09:39
Speaker A
Now, you might be a little bit cynical like me. So, we can check if this actually happened via this command here.
09:45
Speaker A
Docker image LS or image list. As you can see, we have both the latest Ubuntu version and Ubuntu 26.10 along with some other information. So, now I want you to remember that what we just did was pull a image and not a
10:01
Speaker A
container. So, we can use an image to start a container. Now, let me run a container using the image like this.
10:09
Speaker A
Docker run -it --name ubuntu_container ubuntu bash. Now, I get this is a long string of text, but you can see that I'm now in a different environment with a root prompt. I can verify that I'm running Ubuntu by outputting the
10:27
Speaker A
contents of /etc/os-release. And as you can see, I am running Ubuntu. So, we give the container a name and then supply these two special characters I and T. And no, Pennywise isn't going to come and haunt you. In fact, the I
10:42
Speaker A
here stands for interactive and allows you to send commands to the container, whereas the T provides you with a terminal interface. Now, this means that I have access to things that typically run on a Debian base system like the apt
10:55
Speaker A
package manager, for example, even though my main host machine is Arch based and uses Pacman, as you can see here. Now, if I open another terminal window and type docker ps, I can see this container is currently running.
11:09
Speaker A
Pretty cool, right? So, now let me introduce you to two other cool Docker options. The first is docker exec. This command allows you to execute a command in a running container. So, let me first start the container with docker start
11:24
Speaker A
ubuntu container. It is now running. Then, we can use this exec command to run a command in that Ubuntu container.
11:33
Speaker A
So, we do so with docker exec Ubuntu container echo hello world. And this echo hello world here is the command I'm sending to the docker container, which is Ubuntu. So, as we can see, hello world was printed and this is actually
11:49
Speaker A
running in the container. So, to verify this, I can also run another command. So, if I type docker exec Ubuntu container cat Etsy OS release. And as you can see the Ubuntu version verifying it's running within the container and
12:04
Speaker A
not on my system. Now, another cool command that you'd like to know is docker attach. Now, as the name suggests, this allows you to attach to container. So, first let me exit the container. Now, what if I wanted to go
12:16
Speaker A
back into a running container? Well, I can run docker attach Ubuntu container. And now you can see that I'm in the container in a root shell, again like before. So, pretty cool. But please remember, however, that the container
12:29
Speaker A
has to be running to run this command. Now, you can manage this container in various ways, such as by stopping, removing, starting them, and more, which I will explain further in the next section with a different example, which
12:41
Speaker A
is a little bit more complicated. So, a common use of docker is self-hosting apps. So, you're not relying on third-party cloud apps like Netflix or Google Cloud. For example, I have a number of self-hosted services, but one I use a lot is this lovely little
12:55
Speaker A
dashboard here, which lists all of my services and provides me with some useful information like the time and date and the weather, along with other things. However, this service in a docker container on my server. And as you can see, it uses a number of
13:09
Speaker A
different options. Now, this is something called compose, but don't worry about that just yet. I'll explain this a little bit later in the video.
13:17
Speaker A
However, if I were to write this compose file into an entire docker command, it would look like this. Docker run {dash} {dash} name glance {dash} {dash} restart unless stopped {dash} v config app config, dash P 8080, and then glance app
13:35
Speaker A
glance. And once I run this, I'll be able to access it by going to localhost 8080. However, let me break down this long command so you can kind of understand how Docker works. So, first we have Docker run. And this means
13:49
Speaker A
create and start a new container from an image. And the image we are using here is glance app glance. Now, this is at the end of the command. Also, if you don't have the image locally, it will download it for you automatically from
14:02
Speaker A
an online repository like Docker Hub. Then we have dash-dash name. Now, this gives the container a name. So, remember the container and the image are two separate things. So, while this is running, let me look at what is running.
14:14
Speaker A
You can do so with Docker PS. Now, this shows me the containers that are currently running on the system. And as you can see, under the names column, we have glance. Now, you can also run Docker PS-A.
14:27
Speaker A
Now, this will show you all of the containers and even those that are stopped. Anyway, then we have dash-dash restart unless stopped. Now, this just means that if the container is stopped for any reason, it won't automatically start up again. Now, there are other
14:42
Speaker A
options as well. So, please take a look at the Docker restart policy page if you're interested. Then we have this dash V here. So, what is this? Oh, this stands for volume and allows you to add storage to your container. This is
14:55
Speaker A
because by default, containers are volatile, meaning they don't store any data. And of course, many apps we usually need data to store usernames, password, configuration files, databases, etc. So, this dash V here allows us to add storage. Okay, but how?
15:11
Speaker A
Well, let's take this glance example. The installed page tells us that we need to create a local directory, which is named config. So, as you can see in this example directory, I have a folder called config with the example glance
15:25
Speaker A
configuration inside of it. Then you see this colon and then app/config. Now, this is the configuration folder inside the container. So, what happens is that this local folder config here actually maps to this folder inside the container. And this is so the container
15:43
Speaker A
can actually read the data and modify it. Now, remember this concept as it's really important. Now, back to the command and we have this {dash} p here.
15:52
Speaker A
Now, this stands for port. But, what's that? So, a port is simply a virtual point that is usually used for a specific service, allowing it to differentiate between different types of traffic. Imagine you had a parcel and the only information the driver had was
16:08
Speaker A
your road name. Well, he or she needs a house number or the port to know where exactly to deliver what needs delivering. Is that clear?
16:17
Speaker A
Okay. Anyway, we have {dash} p and then 8080. This is the port number we are using and then the colon, which is the port number inside the container. So, remember this mapping thing from before with {dash} v.
16:30
Speaker A
So, the port number at the start is mapping to the port number inside the container using this colon as a separator. Now, this port number doesn't have to be the same. It could be mostly anything within a certain range and most
16:43
Speaker A
certainly it has to be free, meaning another service isn't using it. So, for example, I could make the port 2222. So, on my device, I'd connect to localhost 2222. But, this is actually mapped to 8080 in the container. And lastly, we
16:59
Speaker A
have the name of the image, which is self-explanatory. Okay. So, this container is running right now as you can see in my terminal. This means, however, that when I hit control plus c, the Docker container stops. And if I run
17:12
Speaker A
Docker PS, you can see it's gone. So, to correct this, Docker has an option called {dash} d or daemon mode. This means the container will run in the background. So, let's give that a go using exactly the same command with the
17:25
Speaker A
d added. Give you a me a good old rub. Hey boy. Okay, I hit enter and what? Error response from daemon. Container name is already in use. Okay, well, don't worry.
17:36
Speaker A
This provides a great opportunity to explain how to remove container. So, we can't create a duplicate container with the same name. So, let's remove this old glance container. We do so with Docker rm glance. And rm is just like the Linux
17:51
Speaker A
command, which stands for remove. And then we can check it's removed by doing Docker container ls. This shows us all the containers on our system and just ignore this one here, but the glance one is gone. This means we can now create
18:04
Speaker A
the container again. And this time, as you can see, we get a long string and then the cursor is given back to us.
18:11
Speaker A
This long string is known as the container ID. Now, this is just a unique way to reference different containers.
18:18
Speaker A
So, if we run Docker container list again, you'll see that the start of the container ID is the exact same as the long string we received. Now, we can use this container ID to remove the container. However, how do we stop a
18:32
Speaker A
container? Well, we can't do so with control C because now we're running in daemon mode. The container is running in the background. Therefore, we can do so with the container name or even ID.
18:42
Speaker A
However, on the CLI or command line, you can simply hit tab after you write Docker stop. And this will give you a list of all the active containers, which you can use to auto complete and then run the command. So, running a Docker
18:55
Speaker A
ps, the container has stopped. Pretty easy, right? Now, let's say you don't want either the container or the image on your system right now. Well, you first need to remove the container and then the image. So, we would do Docker
19:08
Speaker A
rm glance. This gets rid of the container completely. Then to remove the container image, remember these are two separate things, we simply use docker rmi glance app/glance, which is the image name. Again, after typing rmi, you can hit tab and it will provide you with
19:26
Speaker A
a list of available images. So, hit enter and poof, just like magic. Now, we can verify it's gone with docker image ls. And just like entry-level jobs in the UK, it's nowhere to be found. Okay, so that was a pretty lengthy section.
19:41
Speaker A
However, if you're going to use docker, you need to know about something called docker compose. So, what is it you may ask? Well, docker compose allows you to manage multiple containers more efficiently by taking these options and putting them into a singular file called
19:57
Speaker A
a docker-compose.yml file. Or, I think the new version is just compose.yml. Now, I won't go into too much detail, but I will provide a brief overview of it. So, what does a compose file actually look like? Well, let me take you to my Raspberry Pi
20:11
Speaker A
server and show you. So, if I take you to the docker folder and a particular service, which in this case is book orbit, you can see this docker-compose file listed here. And opening up, you can see some similar options to before,
20:25
Speaker A
like the container name, the image, the restart policy, ports, and so on among other things. However, this app requires a lot more information and even multiple containers to run. Unlike the previous simple examples, this entire service makes use of two containers. So, compose
20:42
Speaker A
allows us to combine these options into one file, which makes it extremely easy to configure. So, you can just imagine trying to run all of this in a singular line using the more traditional method.
20:54
Speaker A
Also, it makes stopping and starting and even updating each container really simple. For example, I can stop the container using docker-compose down. This command also stops and removes the networks created by composer well and not only the containers and
21:11
Speaker A
then I can also update all of the containers with docker compose pull and once everything is downloaded you can get the service back up with docker compose up dash D. This brings the service back up and puts it into the
21:26
Speaker A
background. Therefore, I can access this book service and read what I want. Pretty awesome. However, the main thing to remember is that wherever you run these docker compose commands this important docker compose YAML file needs to be present or the commands won't
21:42
Speaker A
work. Or you can specify where the compose file is with docker compose dash F and then the path to the compose file.
21:49
Speaker A
This is because the commands look to this file to know exactly what to do and you can try out using docker compose by using this site which will take your standard docker commands and convert them into a lovely docker compose.yml
22:02
Speaker A
file and the link will be in the description. So everybody, that was docker for absolute beginners and as you can see that was a massive topic but I barely scratched the surface. Docker has a million options but the commands I've
22:15
Speaker A
shown in this video are going to be the ones that you you use the most. So I hope after this video you understand docker just a little better.
22:25
Speaker A
Once in a while I dream. [music] Once in a while I think [music] of you.
Topics:Dockercontainersvirtual machinesself-hostingDocker ComposeDocker HubcontainerizationLinuxbeginner tutorialDevOps

Get More with the SozAI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries and speaker detection. 30 minutes free.

Or transcribe another YouTube video here →