Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Docker

Docker is an open-source platform


for developing, deploying, and
running applications inside
containers.
Problem

Developer Tester

The code is The code is not running


absolutely fine. on my system.

The code does not work on the other system due to the
difference in computer environments.
Solutions

VM Docker

Virtual machine can Docker can be the


be the solution. solution.
The boot-up time for a virtual machine is fairly slow in comparison to the boot-up
time for a Docker environment, in which boot-up is almost instantaneous.
How does Docker work ?
Docker works via a Docker engine that is composed of two key elements: a
server and a client; and the communication between the two is via REST
API. The server communicates the instructions to the client.
There are four components that we will discuss in this getting started with
docker tutorial:
Docker client and server
Docker image
Docker registry
Docker container

Docker concepts
Docker containers
Containerization is a type of virtualization in which all the components of an
application are bundled into a single container image and can be run in isolated user
space on the same shared operating system. Containers are lightweight, portable, and
highly conducive to automation.

Docker client(CLI)
The Docker client (docker) is the primary way that many Docker users interact with
Docker. When you use commands such as docker run, the client sends these
commands to dockerd, which carries them out. The docker command uses the
Docker API. The Docker client can communicate with more than one daemon.
Docker Server(Daemon)
The Docker daemon (dockerd) listens for Docker API requests and manages
Docker objects such as images, containers, networks, and volumes. A daemon
can also communicate with other daemons to manage Docker services.

Docker Hub
A Docker registry stores Docker images. Docker Hub is a public registry that
anyone can use, and Docker is configured to look for images on Docker Hub by
default. You can even run your own private registry.

When you use the docker pull or docker run commands, the required images are
pulled from your configured registry. When you use the docker push command,
your image is pushed to your configured registry.
Image
An image is a read-only template with instructions for creating a Docker
container. Often, an image is based on another image, with some additional
customization.

You might create your own images or you might only use those created by
others and published in a registry. To build your own image, you create a
Dockerfile with a simple syntax for defining the steps needed to create the
image and run it. Each instruction in a Dockerfile creates a layer in the image.
When you change the Dockerfile and rebuild the image, only those layers which
have changed are rebuilt. This is part of what makes images so lightweight,
small, and fast, when compared to other virtualization technologies.
Container
is a runnable instance of an image. You can create, start,
stop, move, or delete a container using the DockerAPI or CLI.
can be run on local machines, virtual machines or deployed
to the cloud.
is portable (can be run on any OS).
is isolated from other containers and runs its own software,
binaries, and configurations.

Docker Desktop

Docker Desktop is a free, easy-to-install, downstream application for a


Mac or Windows environment. The application lets you build and share
containerized applications and microservices. Docker consists of Docker
Engine, Docker Compose, Docker CLI client, Docker Content Trust,
Kubernetes, and Credential Helper.

Orientation and setup


Installing
Go to the website https://docs.docker.com/docker-for-windows/install/
and download the docker file.
Double-click on the Docker Desktop Installer.exe to run the installer.

Follow the installation process to allow the installer and wait till the
process is done.
After completion of the installation process, click Close and restart.
Here is the run command you need to get the tutorial started:
docker run -d -p 80:80 docker/getting-started

Make sure you have a supported version of Docker by running this


command:
docker –- version

You can find out more details about your installed version by running:
docker info
Docker The Docker dashboard gives
you a quick view of any

Dashboard containers running on your


machine.

Example - Running Docker Hello World


Open a terminal or command prompt on your computer.
Pull the official "hello-world" image from Docker Hub by running the
following command:

docker pull hello-world


Once the image is downloaded, run the image as a container


using the following command:

docker run hello-world


Docker will then start a container from the image and execute the "Hello,
World!" program, which will display a message in the terminal confirming
that everything is working correctly.
Docker Commands
docker run: starts a new container from an image
docker pull: downloads an image from a registry
docker build: creates a new image from a Dockerfile
docker ps: lists all running containers
docker stop: stops a running container
docker rm: removes a container
docker images: lists all images on the system
docker rmi: removes an image
docker exec: runs a command inside a running container
docker logs: prints the logs of a container
docker inspect: detailed information about a container or image

You might also like