Docker and Containerization (text)

by Sasha Shkrebets last modified Mar 06, 2023 01:19 PM
In this lecture I'll give a brief overview of containerization in Docker. I'll talk about what containers are and why they're useful. In fact, you've already seen one form of containers in this course already. Mininet emulates virtual networks by connecting containers with virtual tunnels.
Welcome back.
In this lecture I'll give a brief overview of containerization in Docker.
I'll talk about what containers are and why they're useful.
In fact, you've already seen one form of containers in this course already.
Mininet emulates virtual networks by connecting containers with
virtual tunnels.
Containers are an operating system level virtualization technology that makes it
possible to run multiple isolated systems,
often Linux, on a single underlying host operating system.
Unprivileged containers now allow users to run software on the host without
actually accessing the hardware.
One of the more prominent instances of containers is Docker.
But previous versions of containerization include LXC, OpenVZ, and Linux vServers.
Containers provide application developers and
service providers increased portability by allowing a development of an application
In a completely contained host environment.
Once an application developer gets an application running in
one containerized environment, the application can then be deployed in
any environment that can host that container.
Another benefit of containerization is isolation,
which allows application developers to deploy applications on shared hardware and
isolated name spaces and environments.
In contrast to virtual machines, which have not only applications and
binaries but also a guest operating system.
A container has only the applications needed to run the service for
that container and any dependencies that that application has.
The underlying host OS and the associated operating system resources are shared.
Making containers significantly more lightweight and
faster to load than virtual machines.
In comparison to virtual machines containers have lower overhead
due to the direct use of operating system system calls
as opposed to less efficient emulated calls.
They do have somewhat less flexibility than virtual machines.
Because the guest OS in the container must be the same as the host OS.
In contrast, a virtual machine can run a completely different operating system than
that of the underlying host.
The file-level copy on write semantics provided by containers also offers
easier backup and simpler caching behavior than many virtual machines provide.
Docker is currently used to deploy distributed applications, for
continuous integration and delivery of multi-tiered services, for
platform as a service deployments, and for application deployment.
Let's take a quick look at Docker in action.
The Docker website provides detailed instructions.
For how to install Docker on a variety of host operating systems.
Once you have Docker installed you can use the Docker run command to fetch and
run a container.
In this particular example I've asked Docker to
run a container with the latest release of Ubuntu.
Since I didn't already have the image installed,
Docker automatically fetched the image and ran it for me.
Once I have a local image with a container,
I can ask Docker to run a command inside that particular container.
Here, I simply issue a command to echo, hello world,
inside that particular container.
What actually happened when I ran that command,
was that it ran inside the Docker container that I just fetched.
You can also use the docker run command to get an interactive shell
inside your container.
So here you can see I'm now inside the container
looking at a standard Linux installation.
Now if I exit the container,
I can also show you how I run the command as a daemon.
In this case I will launch an infinite loop and run it as a demon.
Particular demon does nothing particularly exciting except print hello world over
repeatedly.
Since I'm running the loop as a demon,
the text doesn't come out to the command prompt.
But rather two log that I can view.
To see the containers that are running I can type doc of ps.
And to see the output of any programs running in that container.
I could type Docker logs in the name of the container that's running.
Here you can see I have a very long string of hello world output to the Docker logs.
If I want to stop the container, I simply type Docker stop and
then the name of the container.
And now, when we type Docker ps,
you can see that no containers are currently running.
Because that stopped the running container.
In conclusion, containers are a lightweight means
of deploying applications in a self contained environment.
They're faster to deploy and more lightweight than virtual machines,
making them appealing for deploying and things like applications.
And possibly even network functions.
In the future I expect we may see network functions such as those we've discussed
in a previous lecture deploying containers such as those that Docker provides.
Navigation