Docker is great for portability and container management. We have seen in the previous articles how to set up Docker on your Linux distribution. If you haven’t viewed it then I suggest finishing this article and then view it later which will create a better understanding with Docker and essentials commands . Docker is most efficient in containerizing technologies with their OS.
You can have your own Linux distribution and can also deploy your application. Docker containers can be deployed anywhere on the cloud, locally, or on a virtual machine. They are highly scalable while being lightweight at the same time. you need to know docker and essential commands.
Table of Contents
Having Ubuntu as your Container
If you want to install an Ubuntu image on your Docker, or any other image you can simply run the command to have your container set quickly.
Run the following command
Docker run
docker run -t -i ubuntu /bin/bash

sudo docker run centos /bin/bash

You can also view all the docker images installed by
executing the following command.
Docker images
docker images

You can remove an image by knowing the image id and typing the command
Docker Remove Image
docker rmi d70eaf7277ea
Docker Remove Container
docker rm <container-id>
and the following command will remove containers.
Sometimes docker doesn’t allow to remove the image directly, you have to force remove the image by the flag –force or -f.
Docker inspect
You can view further details of a container by typing in the following command.
docker inspect Repository

Docker container viewing
For viewing all the docker containers with a bit more details you can type the following command.
docker ps -a

Where –a indicates all the images, you can use a specific image id for the individual information.
You can kill a container or image if you don’t want the process to ever reevaluate or become live again. It can be completely terminated by typing in the following.
DOCKER EXEC
docker exec <container id>
This will be able to connect and give access to your container that has already run. When the container’s main process is working (PD1), only then you will be allowed to have access to the running container. You have to run the container first through the above run command.
Docker Restart
You can stop and start your docker container through the following command.
docker restart <container-id>
you can restart multiple containers through a single command by giving more container ids as parameters.
One of the useful flags that you can use is –time , -t and the number of seconds you want the container to restart.
Docker unpause/pause
Docker unpause/pause command unpauses/pauses any container along with all the processes.
You can pause/unpause one or more than one container through a single command, with container names as parameter
docker unpause [container1], [container2]
docker pause [container1],[container2]
Docker stats
This command shows the data stream, memory and CPU consumption of the container at that time.
docker stats <container-id>
