Day 16 Task: Docker for DevOps Engineers.

Day 16 Task: Docker for DevOps Engineers.

Docker

Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know your code will run.

Use the docker run command to start a new container and interact with it through the command line.

The command to run a container from an image is docker run <img_name>

This hello-world image was not found locally, so docker pulled it from the docker hub repository for us.

To check all the stopped and running containers- docker ps -a

You can also give a name to the container using --name "any_name" argument-

Here, you can see in the last column that the latest container has the name "hello". If you don't give any name, docker randomly gives any name to it.

You can also assign a port number to a container using --port argument -

Here, you can see in the port column -

Use the docker inspect command to view detailed information about a container or image.

To check all the information on any image or container, do docker inspect <container/image_name>

Use the docker port command to list the port mappings for a container.

To use the port command, a port must be assigned to a container while running a container(like for nginx, we have done above).

To list port mappings for a container - docker port <container_name>

Use the docker stats command to view resource usage statistics for one or more containers.

We will use the docker stats command to view resource usage statistics for one or more containers.

Use the docker top command to view the processes running inside a container.

We will use the docker top command to view the processes running inside a container.

Use the docker save command to save an image to a tar archive.

To save an image to a tar file - docker save <image_name>

You can give --output or -o to write to a file, instead of STDOUT.

No alt text provided for this image

Use the docker load command to load an image from a tar archive.

To load an image from a tar archive, docker load [options] <tar_file>

options:

  • --input , -i : Read from the tar archive file, instead of STDIN

  • --quiet , -q : Suppress the load output

No alt text provided for this image

So, we have learned the basic commands used in Docker.

Thanks for reading!

#devops#90DaysOfDevops#TrainWithShubham

Let's connect on Linkedin - linkedin.com/in/namya-khullar-7b5758200