Frequently
use Docker
commands
Docker is well-known and famous containerization platform , in this article i'll be sharing some frequently use docker command and which will help in your work. There are network and volume section which elaborates more with pictorial representation.
Here we go...
Docker Commands
docker container ls
docker container ls -a
docker container run -d nginx
docker container inspect 182 | less # to get an IP of running container
docker container pause 182
After pausing you wont be able to access this
docker container unpause 182
To Stop and Kill Container
docker container stop 182
To go inside the container
docker container exec -it ngnixContainer bash
Network in docker
docker network ls
docker network inspect add7666agsg
If you want to create your own
network
docker network create -d bridge my-bridge-network
Image network.jpg
docker network inspect ba858ba01ad3
Image network-inspect.jpg
docker container run -d --name nginx3 -p 8081:80 --network my-bridge-network nginx
After this if you run the following command than it shows
that newly created container is connected to that defined network
docker network inspect ba858ba01ad3
Image network-linking-container.jpg
Docker Volumes-> docker volume is use to persist data so in case if container goes down or delete than we can save the data
To create a docker volume use the below command - volume
docker volume create volume1
docker volume ls
To attach a volume to container and mount point which is created
within container
docker container run -d –name nginx4 -v
volume1:/volume1 -p 8085:80 nginx
in an above command left side keyword volume1 is host volume which stores on local host or local machine while right side "volume1" is mount point for within container
Refer an image below: volume.jpg
TO go inside a volume , follow the below path
cd var -> cd lib -> cd docker -> cd volumes
-> ls
image volume-list.jpg
To inspect a volume use the following command
docker volume inspect volume1
refer an image showing below: volume-inspect.jpg
If you notice in an image above mount point shows an exact path of volume along with Name.
docker image ls
docker image rm logstash
docker image history logstash
docker image save logstash > logstash.tar
To load image from standard input
docker image load < logstash.tar