Getting Familiar With Docker Commands Docker Terms: Docker - Part 3 B
Docker Linux Tutorials

Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 B

In the previous tutorial Part 3 A, we learned 11 Command to get familiar with Docker terms and its terminology. Here I will learn 12 more commands used in Docker and its implementation

Just in case, if  you did miss Previous two tutorial regarding Docker can be read here:

Part 1: What Is Docker And Concept Of Containers With Virtualization?
Part 2: How To Install Docker On CentOS/RHEL 6/7? And Learn Docker HUB Registration
Part 3A: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 A
Part 4: How To Perform Task Like Install, Run And Delete Applications Inside Docker Containers

Let’s Start

Command 13: Stop A Docker

Now if our container is working/running and we got its ID by issuing docker ‘ps’ command previously. Now to stop that container following command

Syntex: docker stop container ID or auto-generated name.



Command 14: Add Name To Docker Container On Local

consider a situation when you have good numbers of containers and you can’t remember so you don’t have to remember the container ID. You can give a unique name for every container using the –name option as this following example shows:

Syntex: docker run –name unique_name Image Command

Command 15: Use of Name To (start, stop, remove, top, stats)

Now as we have given a unique name to the container so we can do a lot of work with container unique name like following.

Note: Sometimes there is no output because the command was in execution which was used to create the container.

Command 16: Start Docker Container Interactive Shell

To start an interactive session with into a container shell, and want to run commands as you do on any other Linux session, please run following command

Note: Run bash command to get bash shell

Here, Centos is the name of the image we download from Docker Hub
-it is used to mention that we want to run in interactive mode.
/bin/bash is used to run the bash shell once CentOS is up and running.

Command 17: Quit Docker Container Interactive Shell

Now if you want to run quit this interactive session from the container with the host. You can do this by typing exit in an interactive shell. The exit command terminates all the container processes and stops it.

Command 18: Keep Docker Shell Session Active

As the previous command kill all the running process of a container after exiting interactive shell mode. Now if you don’t want to kill the running container process and want to keep the container in running state. Also, want to exit the interactive shell session and return to the Host Terminal, you can do this by pressing Ctrl+p and Ctrl+q keys.

Command 19: To Reconnect With Running Container

Well with the previous command we kept a docker running even after exiting the interactive shell now to reconnect that interactive shell we need the container ID or name of that container. Use the ‘docker ps’ command to get the ConatinerID or name and use the following command to get reconnected.

Now Use this ContainerID or Name to Reconnect Container.

Syntex: docker attach <container id>



Command 20: To Stop A Running Container

To stop and kill a docker from the host, use the following command
Syntax: docker kill <container id>

Command 21: Inspect A Docker

This command is used see the details of an image or container. This Command provides lots of information about the Docker Image.
Syntax: docker inspect Repository

Repository − This is the name of the Image.

Command 22: Docker Logs

When there is a production, we always need logs for data analysis and get logs of container from the host machine we need to run following command but to do this we require a ContainerID

Syntex: docker logs ContainerID

Command 23: Get Image ID’s Only

If you require image ID only for any purpose you may issue the following command to get IDs

As you can see this command is used to return only the Image IDs of the images.

q− It tells the Docker command to return the Image ID’s only

Command 24: Docker History

docker history is the command to check all the commands which were fired/ran with an image via a container.

Syntax: docker history ImageID

This command will show all the commands that were run with the CentOS image.

ImageID − This is the Image ID for which you want to see all the commands that were run against it.



Read More:

Part 1: What Is Docker And Concept Of Containers With Virtualization?
Part 2: How To Install Docker On CentOS/RHEL 6/7? And Learn Docker HUB Registration
Part 3A: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 A
Part 3B: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 B
Part 4: How To Perform Task Like Install, Run And Delete Applications Inside Docker Containers

Kapendra
Love to write technical stuff with personal experience as I am working as a Sr. Linux Admin. and every day is a learning day and Trust me being tech geek is really cool.
http://kapendra.com

Leave a Reply