Docker commands line reference

In this tutorial, List all useful commands for docker. How to restart one or more containers and stop one or more containers and so forth. The description useful Docker commands as the link below

What is Docker?

  • Docker is a platform for developers and sysadmins to build, ship and run application”. It’s allow run containers and A container running Application. It’s dependencies on the host operating system.
  • Docker is OS level Virtualization.

All containers are started based on Docker image. To find existing images at https://hub.docker.com/

List all Docker commands

To use command find an image

$ docker search <name>

To run a container based on a Docker Image. The default, to rune command in the foreground. To rune in the background with option -d. Docker to rune latest version available.

$ docker run <options> <image_name>

Find out running containers

$ docker ps

More details running a container

$ docker inspect <name-container>|<container-id>

Providing logs details running a container

$ docker logs <name-container>|<container-id>

To access a container with <host-port>:<containers-port>

$ docker run -d --name <name-container> -p <host-port>:<containers-port> <Image>

Persisting Data for containers

$ docker run -d --name <name-container> -v <host-dir>:<container-dir> <Image>

accessing to a bash shell inside of a container

$ docker run -it <name-container> bash

List all the images on the host

$ docker images

To use docker build command to build the image

$ docker build -t <name> .

Docker Ignoring Files during Build, to exclude sensitive files during build the image.

$ echo file_name.txt >> .dockerignore

To create Data Container

$ docker create -v /config --name dataContainers busybox

Copy files to data containers

$ docker cp config.conf dataContainers:/config/

Mount Volumes From data containers

$ docker run --volumes-from dataContainers ubuntu ls /config

To Export / Import for data Containers

 $ docker export dataContainer > dataContainer.tar
 $ docker import dataContainer.tar

Docker communicating between containers

$ docker run --link <container-name|id>:<alias> New_container

How to get quick stats on Docker containers

$ docker stats

Conclusion

Thought the article, you can use Docker commands line reference as above. I hope will this your helpful.

,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.