What is container?
In DevOps, a container refers to a lightweight, isolated, and portable environment that encapsulates an application and its dependencies. Containers provide a consistent and reproducible way to package software, allowing it to run reliably across different computing environments.
What is docker ?
Docker is an open-source platform that enables developers to automate the deployment and management of applications within lightweight, isolated containers.
What is docker runtime ?
Docker runtime refers to the component of the Docker platform responsible for executing and managing containers. It is the underlying engine that enables the creation, deployment, and execution of containerized applications using Docker.
runc - works with os, starts and stops the container
containerd - managing runc and containers, image management, connecting with networks etc.
What is docker engine ?
Docker Engine, also known as Docker Daemon or Docker runtime, is the core component of the Docker platform. It is responsible for building, running, and managing Docker containers.
Docker Daemon: The Docker Daemon (dockerd) is a background process that runs on the host machine. It listens for Docker API requests and manages container lifecycle operations, such as creating, starting, stopping, and deleting containers.
Docker Client: The Docker Client (docker) is a command-line interface (CLI) tool that allows users to interact with the Docker Daemon. It provides a user-friendly way to issue commands and manage Docker containers, images, networks, and other resources.
Docker Images: Docker Engine uses container images as the basis for creating and running containers.
Networking and Storage: Docker Engine provides networking and storage capabilities for containers. It allows containers to communicate with each other and the external world through network interfaces.
Docker Registry: Docker Engine integrates with Docker Registry, a centralized repository for storing and distributing container images.
What is orchestration ?
Docker orchestration provides the ability to manage a large number of containers and ensures that they run efficiently, reliably, and in a highly available manner. It enables the deployment of complex applications that consist of multiple interconnected containers, working together as a cohesive system.
Docker/Container Image -
Image in simple words can be said as the step by step instructions for an application whereas container is the running instance of the container. A Dockerfile is a text file that contains a set of instructions used to build a Docker image.
Open container initiative (OCI) -
Why it was created -
There were different container technologies with varying formats and runtimes, which made it challenging to switch between them or use them together seamlessly.
What does it do -
To establish open industry standards that promote interoperability among container technologies. By creating common specifications for container images and runtimes, the OCI aimed to ensure that containers and container runtimes could work together regardless of the specific implementation.
Docker CLI commands -
docker run hello-world
- looks for hello-world image locally, if not present then pull from online and created container of it, run here means it runs an image to create a container.docker images
- give list of images downloaded on local machinedocker images -q
- gives list of id of all imagesdocker pull ubuntu
- only downloads the image and not run it.docker pull ubuntu:16/04
- downloads the ubuntu 16.04 version imagectrl+d
- to exit out of container interactive shell enviromentdocker run
-it ubuntu - it flag states interactive enviroment here which doesn’t exit out of it’s owndocker ps
- to see all containers currently runningdocker ps -a
- also shows all the containers that are stopped alsodocker container ls
- list all the containersdocker container exec -it <container-id> bash
- connect the bash to the running container only specified by the id, doesn’t work if container is not runningdocker start <id>
- starts the container with the iddocker stop <container-id>
- stops the running container with the help of it’s iddocker rm <id>
- removes the particular containerdocker inspect <id>
ordocker inspect ubuntu
- gives all the information about the containerdocker container prune -f
- removes all stopped containersdocker run alpine ping [
www.civo.com
](civo.com)`` - run alpine image and then pings civodocker run -d alpine
- docker detach(mode) container process and run it in the backgrounddocker run ubuntu echo hey
- displays hey in terminal after running imagedocker logs —since 5s <id>
- displays logs of particular container id in the past 5sdocker rmi alpine -f
- removes the alpine image forcefully but not the containerdocker run -d -p 8080:80 nginx
- runs the container and makes it available to port using p flag and then specifying port number. -p takes to argument first the port on which we want to expose : then the default port of the nginx in the container which is by default 80.docker commit -m “new image making” <id> <image-name>
- create your new image over the previous image-name now which we can share with others.docker rmi $(docker images -q)
- it will remove all the images
What are layers ?
In Docker, images are made from layers. Every layer represents a change made to the previous layer, such as adding or modifying a file. Layers are immutable, meaning that once they are created, they cannot be changed. When a new image is created, it is built from the layers of the base image, with each additional layer representing changes specific to that image. This layering system allows Docker to efficiently share and store images, as well as quickly create new images based on existing ones.
Dockerhub ?
Similar to github we can download images and upload our images too.
docker login
- To login from command line into dockerhubCreate you own dockerfile which then will be used for image
Go to the directory where your application code is located.
Create a new file called Dockerfile.
Inside the Dockerfile, specify the base image you want to use.
Add any necessary dependencies or libraries your application may need.
Copy your application code into the Docker image.
Set any necessary environment variables.
Specify the command that should be executed when the Docker image is launched.
Build the Docker image using the
docker build
command.docker build .
- to make docker image by a file in current directorydocker build -t myimage
- to make docker image by the name myimageRun the Docker container using the
docker run
command.
What is gRPC?
gRPC is a high-performance, open-source framework developed by Google that allows developers to build distributed systems and microservices using a message-passing protocol. It is designed to be fast and efficient, with support for a wide range of languages and platforms. In Docker, gRPC can be used to create scalable and reliable microservices that can communicate with each other using a simple and efficient protocol.
In simple terms we can say that, Independent containers can definitely talk to each other using gRPC. Docker allows you to run multiple containers on the same machine or across different machines, and gRPC provides the communication mechanism between these containers.
Follow -
Comment below for suggestions and improvement :) Follow me for more such content 😀. If you have any doubts you can message me, and I will respond asap :)