#Day 16 - Introduction to Docker
Passionate AWS Developer | DevOps Engineer with a strong background in cloud architecture and solutions engineering. Leveraging the power of Amazon Web Services (AWS), knowledge of the AWS global infrastructure, design and implement robust cloud-based solutions that align with clients' specific needs.
What is Docker?
Docker is a platform that allows you to build, test and deploy applications quickly.
Docker engine-
docker engine is a service that is installed on the host OS.
Docker Container-
The container is an entity that is installed on the docker engine. It has code, required libraries, OS, and commands to run.
Docker Engine is a service that allows running any container on Linux, windows, or mac os on any host OS which uses Docker d and docker CLI.
The Docker engine has three components:
Docker daemon
Docker CLI
Container d
The Docker daemon is responsible for all the background process that helps to manage containers. It is responsible for running containers and managing docker services.
Docker Images- It is a read-only binary template used to create docker containers.
The container is made from Docker Image and Docker Image is made from Docker File.
Docker Hub- This is a repository for docker Images.
Docker file- Set of Instruction.
Some Docker Commands Covered:
docker build: To build Docker image from docker file
vim dockerfile: To create dockerfile.
docker pull: To load docker image from docker hub.
docker images: To view all the docker images.
docker run: to build container
docker ps: To see the containers.
docker exec -it <container id> sh: To go inside of docker container.
Task: 01
Use the docker run command to start a new container and interact it with through the command line.
Example: 01
docker run hello-world

Task:02
Use the docker inspect command to view detailed information about the container or image.
docker inspect hello-world

Task:03
Use the docker port command to list the port mapping for a container.
sudo apt install nginx
docker run -d -p 8080:8080 nginx
docker port <container-id>

Task: 04
Use the docker stats command to view resource usage statistics for one or more containers.
When we run the docker stats commands it continuously updates and displays the table with statistics for each specified container. The table include column like container id, name, CPU, mem usage, mem%, network I/O, block I/O, and PIDs.
docker stats <container-id>
docker stats f7f13eeec556

Task: 04
Use the docker top command to view the processes running inside a container.
docker top <container-id>
docker top f7f13eeec556
Task:05
Use the docker save command to save an image to a tar archive.
docker save -o <new-tar-name-image> <inmage_name>
docker save -o nginx_image.tar nginx
ls -lh nginx_image.tar

-o to specify output of file name
<new-tar-name-image> to specify the new name of tar file.
[ls -lh] is used to view the details of tar file saved.
This command creates a tar archive file called "nginx_image.tar" containing the "nginx" image.
Task:06
Use the docker load command to load an image from a tar archive.
docker load -i <name-of-tar-file>
docker load -i nginx_image.tar

The docker load command reads the contents of the specified tar archive file from the standard input and imports the images contained in the archive into your local Docker image repository.
Conclusion:
The Docker commands are useful in building, testing and deploying applications using the containerization concept. It manages the application by creating docker files, images and containers.




