Intro Docker Command
Table of contents
Intro command
Live container list:
sudo docker ps
Run container from image:
sudo docker run IMAGE_NAME
List of all contianers in docker engine:
sudo docker ps -a
List of all contianers with id in docker engine:
sudo docker ps -aq
Simple remove container :
sudo docker -rm CONTAINER_IDENTITY
Advance remove container:
sudo docker rm $(sudo docker ps -aq)
List of images in our docker engine
sudo docker images
Get image from docker hub
sudo docker pull IMAGE_NAME
Remove image on docker engine
sudo docker rmi IMAGE_NAME
Advance Command
Commit
If we want to change image and save in new image use this command like below
sudo docker commit CONTAINER_ID NEW_IMAGE_NAME
Save/Load
If we want export image as .tar.gz file we can use this command
sudo docker save -o alpine_mohsen.tar.gz alpine_mohsen:latest
sudo docker load -i alpine_mohsen.tar.gz
Execut Command
When we want to run command in running container we can use exec command like below
sudo docker run exec -it CONTAINER_ID COMMAND
Volume
When we use database images we should mount directory from our host to container to store data in host
sudo docker run mongo -v HOST_DIR:CONTAINER_DIR
Docker File
Sometime we want create our custom image we do it with docker file and build it with build command.
Link
We use link command for connect containers to each other like below
sudo docker run --link CONTAINER_NAME:NAME_WE_USE
Get Benchmark from our Microservice
We can send bulk request to our web server with ab tool like below
ab -n 1000 -c 5 SERVER_ADDRESS
