Docker is a set of platform as a service products that uses OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.

There are some basic commands, which can help to you.

!!! Running container list →
$ sudo docker container ls

!!! All containers list →
$ sudo docker container ls -a

!!! Start stoped container →
$ sudo docker container start container_name

!!! Stop container →
$ sudo docker container stop container_name

!!! Enter in bash of any existing container →
$ sudo docker container exec -it container_name bash

!!! Start and make a container with name and port →
$ sudo docker container run -d -p 3306:3306 --name container_name -e
MYSQL_RANDOM_ROOT_PASSWORD=yes mysql sudo docker container run -d --name given_name -p 80:80 container_name

!!! Enter in bash of any new container →
$ sudo docker container run -it --name given_name container_name

!!! Pull any library →
$ sudo docker pull library_name

!!! Remove container →
$ sudo docker container rm 7388 c0a7 d9e5

!!! Print log →
$ sudo docker container logs container_name

!!! Running container →
$ sudo docker container top

!!! Running container list →
$ sudo docker image ls

!!! State of container →
$ sudo docker container stats container_name

!!! Complete details of the container →
$ sudo docker container inspect container_name

!!! Complete configuration of a container →
$ sudo docker container config container_name

!!! Check port of any container →
$ sudo docker container port container_name

!!! Find Ip of container →
$ sudo docker container inspect container_name

!!! Show networks →
$ sudo docker network ls

!!! Inspect any network →
$ sudo docker network inspect network_Id

!!! Create a network →
$ sudo docker network create my_network

!!! Docker any command help →
$ sudo docker network create --help

!!! Connect a container to network →
$ sudo docker network connect network_Id container_name

!!! Disconnect container to a network →
$ sudo docker network disconnect network_Id container_name

!!! Connect another container in an existing network →
$ sudo docker container run -d --name new_container --network existing_network container_name

!!! Enter in bash →
$ sudo docker container run --rm -it centos:7 bash

!!! Pull image →
$ sudo docker image pull image_name:latest

!!! Image history →
$ sudo docker history image_name

!!! Inspect image →
$ sudo docker image inspect

!!! login →
$ sudo docker login

!!! Make same repo different according to my username →
$ sudo docker image tag repo_name username/repo_name

!!! Push image in my account →
$ sudo docker image push username/repo_name

!!! Build a Docker image by Dockerfile →
$ sudo docker image build -t testnode .

!!! Make Docker image via DockerFile →
$ sudo docker image build -t name_of_image . (In the same Directory)

!!! Clean all dangling images →
$ docker image prune

!!! Clean all System (images container everything) →
$ docker system prune

!!! Check all size and everything of VM →
$ docker system df

!!! Remove all images which are not in use →
$ docker image prune -a

!!! Remove default local and remote instance →
$ docker-machine rm default

!!! Check docker-machine →
$ docker-machine ls

!!! Create docker-machine →
$ docker-machine create

!!! Find volumes →
$ docker volume ls

!!! Show continue log →
$ sudo docker container log -f name_of_container

!!! Mount local directory with container →
$ sudo docker container run -d -p 4000:4000 -v
/home/ankit/testDockerFile:/mnt/testDockerFile --name given_name container_name

!!! Connect localhost to container →
$ sudo docker container run --net=host -d -p 5000:5000 --name given_name container_name

!!! Setup all containers →
$ sudo docker-compose up

!!! Setup all containers in the background →
$ sudo docker-compose up -d

!!! Stop all containers →
$ sudo docker-compose down

!!! All containers log →
$ sudo docker-compose logs

!!! Compose containers list →
$ sudo docker-compose ps

!!! Compose containers top list →
$ sudo docker-compose top

!!! Compose help →
$ sudo docker-compose --help

!!! Docker information on our machine →
$ sudo docker info

!!! Initiate swarm →
$ sudo docker swarm init

!!! Check node →
$ sudo docker node ls

!!! Check help →
$ sudo docker node --help

!!! Docker service →
$ sudo docker service --help

!!! Start docker service →
$ sudo docker service create alpine ping 8.8.8.8

!!! Service list →
$ sudo docker service ls

!!! For service →
$ sudo docker service ps service_name

!!! Inspect service →
$ sudo docker service inspect service_name

!!! Update services →
$ sudo docker service update service_name --replicas 3

!!! Create linux-machine →
$ sudo docker-machine create node1

!!! Create a network →
$ sudo docker network create --driver overlay mydrupal

!!! Watch services →
$ sudo watch docker service ls

!!! Create service →
$ sudo docker service create --name search --replicas 3 -p 9200:9200
elasticsearch:2

!!! Direct hit via command line →
$ curl localhost:9200

I’m a MERN Developer. ( Redux | AWS | Python ) I enjoy taking on new things, building skills, and sharing what I’ve learned.