# 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.

# **Tasks**

* As you have already installed Docker in previous days' tasks, now is the time to run Docker commands.
    

```plaintext
sudo apt-get install docker.io -y && sudo chown $USER /var/run/docker.sock
```

### **Use the** `docker run` command to start a new container and interact with it through the command line. \[Hint: `docker run hello-world` \]

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721373670444/4e163698-7c2d-477a-b113-975f98c7b180.png?auto=compress,format&format=webp align="left")

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

```plaintext
docker inspect <CONTAINER_ID>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721373901209/ae592031-80d5-4c98-8b08-797f82dde2dc.png?auto=compress,format&format=webp align="left")

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

```plaintext
docker ps
```

```plaintext
docker port <container_id>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721374164232/83f4b840-5db9-4dda-b1c7-d4aec128a3c4.png?auto=compress,format&format=webp align="left")

The`docker port` command specify the port mapping of its containers.

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

```plaintext
docker stats <container_id>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721374337838/5ed4debe-7e18-4fb2-8803-514e91806c99.png?auto=compress,format&format=webp align="left")

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

```plaintext
docker top <container_id>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721374478645/e3a1b841-4b50-4cb1-8dde-a687f510e927.png?auto=compress,format&format=webp align="left")

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

```plaintext
docker save -o <output_tar_file_name>.tar <image_name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721374712297/88f92290-ff1b-4dfc-b3e1-e3a182324173.png?auto=compress,format&format=webp align="left")

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

```plaintext
docker load -i <input_tar_file_name>.tar
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721374876630/79e0a219-726c-4135-83b9-42d56d1b178f.png?auto=compress,format&format=webp align="left")
