Understanding Docker
Docker provides lightweight virtualization on your desktop using containers. Here’s what happens when you “docker build”, “docker pull”, “docker run”:
1. Docker Client talks to the Docker Daemon
2. Docker Daemon manages containers and images
3. Docker Registry stores images like on Docker Hub
When you “docker run” a container:
– Pull image from registry if not cached locally
– Create new container
– Give it a filesystem
– Connect to network
– Start container
Docker uses containerization, not hardware virtualization. Containers share the host kernel so a full OS image isn’t needed.
Docker Build
With the Dockefile created, an image now needs to be built. For that we use the docker build command.
Make sure you are at the same level as the Dockerfile
location, although you can specify its location with command-line options.
$ docker build --tag intro-netautomation:standalone --file Dockerfile.standalone .
The --tag <name:tag>
will specify the image name and optionally a tag.
The --file <dockerfile path>
will specify the Dockerfile filename name.
The .
at the end is to look for the Dockerfile
in the current directory and its “context” (folders and files needed to build the image). Though we have manually specified the Dockerfile.standalone
file, with the .
we are also specifying the directory to copy the other project files and folders from.
The result will be a Docker container image named intro-netautomation
with the tag standalone
. To verify the images and general specifications you can run:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
intro-netautomation standalone 1abe9d092bfe 10 minutes ago 159MB
...
Docker isolates resources with groups and namespaces without duplication. Containers get their own filesystem but don’t duplicate the full OS.
The layered filesystems allow efficient use of storage and quick duplication of container environments.
Docker is a great packaging technology – bundling the app, libraries, dependencies – everything needed to run. This standardized packaging makes Docker images popular in the cloud, even when container runtimes like containers or CRI-O are used instead of Docker itself.
So Docker provides lightweight virtualization on desktops, while also being an excellent packaging technology for apps in the cloud.
5 facts that you should know about Docker.
1/ Portability
Docker packages your application and its environment into a single image, runnable on any machine with Docker installed.
No more ‘works on my machine’ problems! 😉
2/ Efficiency
Docker containers are lightweight and share system resources.
This means you can run more applications on the same hardware.
3/ Microservice Friendly
Docker is ideal for breaking down applications into smaller, independent components (microservices).
This makes development and updates faster and more flexible.
4/ Scaling Made Easy
Docker works hand-in-hand with orchestration tools like Kubernetes, allowing you to manage and scale complex applications across multiple servers effortlessly.
5/ Made for Developers by developers
Docker streamlines development, making setup quick and eliminating environment conflicts between developers and production.
More information
What is Docker?
◾ Docker is a platform that utilizes containerization technology to simplify the development, deployment and management of applications.
◾ It has actually become a fundamental tool in modern software development, enabling faster development cycles, improved collaboration and easier scaling of applications.
Docker was born out of the frustration with the ‘works on my machine’ problem. 😀
Developers often faced issues where applications worked perfectly fine on their local environments but failed when deployed to different servers or environments.
This was due to inconsistencies in underlying operating systems, libraries and dependencies.
Docker aimed to solve this by providing a standardized way to package and distribute applications with all their dependencies.
Docker was first released as an open-source project in March 2013 by Solomon Hykes and the team at dotCloud (later renamed Docker, Inc.).
The initial development of Docker took place in France as an internal project within dotCloud. It was then publicly introduced at PyCon in Santa Clara, California, in 2013.
Today Docker helps thousands of engineering teams work smarter not harder.
More Docker references:
Visual Studio Code – Code Editing. Redefined. https://code.visualstudio.com/.
Container workflows at Pawsey: Introduction to Docker. https://pawseysc.github.io/container-workflows/01-docker-intro/index.html.
Docker Images vs Containers – All You Need To Know. 16 Oct. 2019, https://www.dockerjet.com/docker-images-vs-containers.