- Ubuntu
docker rm -f $(docker ps -a -q)
- Window
$containers = docker ps -a -q
foreach ($container in $containers) { docker rm $container -f }
docker image prune -a
- Ubuntu
docker rmi -f $(docker images -q)
- Window
$images = docker images -a -q
foreach ($image in $images) { docker image rm $image -f }
docker save -o [path]/<file_name>.tar images_name:tag new_images_name:tag
docker load -i [path]/<file_name>.tar
docker search <key>
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
docker commit -m "upload" c3f279d17e0a <your_docker_hub>/new-repo:tagname
docker push <your_docker_hub>/new-repo:tagname
docker push IMAGE [REPOSITORY[:TAG]]
docker tag local-image:tagname new-repo:tagname
docker push <your_docker_hub>/new-repo:tagname
docker pull <repository>
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
docker run --name=mysqlCon -p 3306:3306 -d -e MYSQL_ROOT_HOST=% -e MYSQL_ROOT_PASSWORD=123456 mysql/mysql-server:5.7
docker logs [container name]
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
sudo docker exec -it <container_id> sh
sudo docker exec -it mysqlCon mysql -uroot -p
docker rmi [OPTIONS] IMAGE [IMAGE...]
docker rmi -f <your_docker_hub>/test:v1
docker ps # containers are running
docker ps -a # show all
docker container start/stop/restart/rm [container id]
docker stop/rm $(docker ps -a -q)
docker rmi -f $(docker images -a -q)
docker volume create [volume name] Tạo mạng mới
docker volume inspect [volume name] Xem chi tiết mạng
docker volume ls Hiển thị những mạng đang có
docker volume rm [volume name] Xóa volume
docker volume prune Xóa toàn bộ volumn
docker volume create mysql_data
docker container run --name mysql -v mysql_data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql:5.7
docker network create [nerwork name] Tạo mạng mới
docker network inspect [nerwork name] Xem chi tiết mạng
docker network ls Hiển thị những mạng đang có
docker network rm [nerwork name] Xóa mạng
docker network prune Xóa đồng loạt các mạng không sử dụng
docker network connect [nerwork name] Tạo kết nối mạng
docker network disconnect [nerwork name] Ngắt kết nối mạng
docker network create --subnet 192.168.1.0/24 network1
docker run -itd --name=container1 --network network1 busybox
docker run -itd --name=container2 --network network1 busybox
docker attach container1
ping 192.168.1.3