Learning Docker: Part 1
“Study without desire spoils the memory, and it retains nothing that it takes in.” — Leonardo da Vinci
What is Docker?
Docker is a set of platform as a service products that uses OS-level virtualization to deliver software in packages called containers. A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.
Why would you use Docker?
- Containers solve dependency conflicts Docker runs your app in a container of its own, so it’s easy to add another app with its own container in the same docker image.
- Easily scalable You can use an orchestrator to easily automate the the creation of multiple containers in a docker image.
- Seamless upgrades Orchestrator can gradually replace every container(older versions) with the container running the new version, and upgrade the older versions of the container seamlessly while routing the traffic, so that there is no interruption of service.
Prerequisites
- Understand basics of Python, Java, .Net or Php
- Git
Container
A container is what we eventually want to run and host in Docker. A container runs inside the Docker host isolated from the other containers and even the host OS. It cannot see the other containers, physical storage, or get incoming connections unless you explicitly state that it can. It contains everything it needs to run: OS, packages, runtimes, files, environment variables, standard input, and output.
Images
Any container that runs is created from an image. An image describes everything that is needed to create a container; it is a template for containers. You may create as many containers as needed from a single image.
Registries
Images are stored in a registry. Each container lives its own life, and they share a common root: their image from the registry.
Using Docker Images
Running Container
Run this after you install Docker on your system. You can also try it here
docker run hello-world
You’ll get a message telling that you have successfully run your first container.
This command basically creates a container based on hello-world
image. But you never made an image, right? The hello-world
image is downloaded from Docker hub which is a repository of various Docker images.
The hello-world
image, whenever started will output some text to the console.
Let’s end it for now. You can find the link of Part 2 here
Personal blog of Ram Shankar Choudhary. I’m an engineering student working on various projects. I learn in public and write about everything I know.
You may follow me on twitter or join my newsletter for latest updates.