Starting with Docker
Have you ever heard someone saying "But it works on my system" . That's where docker comes into play. Docker provides the ability to package and run an application in a loosely isolated environment called a container.
Docker architecture
The Docker client and daemon communicate using a REST API.
Docker daemon
The Docker daemon (dockerd
) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes
Docker client
The Docker client is used to communicate with the Docker.
Docker registries
It is a place where Docker images are stored. Docker Hub is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default
Basic terminology
Docker Image
Docker Image is a read-only template, it contains the instructions for creating a Docker container. A container moving from one Docker environment to another with the same OS will work without changes because the image includes all the dependencies needed to execute the code. A single image can be used to create multiple containers.
Docker file
We can use images either by pulling from Dockerhub or by creating our image using a Docker file. 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.
example of a docker file
FROM python:3.9
COPY . .
RUN pip install -r requirments.txt
CMD ["python","manage.py","runserver","0.0.0.0:8000"]
Containers
A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI. You can consider the container as an isolated workspace.
Docker Engine :
It is an open-source containerization technology for building and containerizing your applications. Docker Engine acts as a client-server application with:
A server with a long-running daemon process
dockerd
.APIs which specify interfaces that programs can use to talk to and instruct the Docker daemon.
A command line interface (CLI) client
docker
.
Some of the docker commands are:-
docker run
command to start a new container and interact with it through the command line.docker inspect
command to view detailed information about a container or image.docker port
command to list the port mappings for a container.docker stats
command to view resource usage statistics for one or more containers.docker top
command to view the processes running inside a containerdocker save
command to save an image to a tar archive.docker load
command to load an image from a tar archive.
Thank you for reading!!