#Day16: Docker for DevOps Engineers. #90DaysofDevOps

#Day16: Docker for DevOps Engineers. #90DaysofDevOps

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 we have already installed docker in previous days tasks, now is the time to run Docker commands.

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

Check if docker status is active using

systemctl status docker

To activate, use

systemctl restart docker

Check status again

now, docker pull python

if it shows error saying "Got permission denied while trying to connect to the Docker daemon socket" you need to create a group called docker and add user in it

sudo usermod -aG docker ${USER}

You would need to loog out and log back in so that your group membership is re-evaluated.

now use docker pull python

Check images downloaded using

docker images

Create container from the image

docker run -it python /bin/bash

View all containers using

docker ps -a

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

docker inspect affectionate_ptolemy

To start a new container and interact with it through the command line, you can use the following command:

docker run -td --name <container name> -p 80:80 <image name>

To see all containers:

docker ps -a

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

docker port <container_name>

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

docker status <container name>

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

docker top <rohitsimage>

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

docker save -o <image>.tar <image name>

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

docker load -i <image.tar>