Very useful docker commands with examples for container operations. Here we are presenting a list of docker commands for Image, Container, Volume, Network, docker-compose, docker-machine, Swarm.
Commands
$ docker build --tag .
$ docker build --tag --no-cache .
$ docker images
$ docker images :
ex) docker images mysql:latest
$ docker rmi
I think that it is common when wanting to erase it collectively
# Unused Image
$ docker rmi $(docker images -f "dangling=true" -q)
# Repository specification
$ docker images {REPOSITORY_NAME} -aq | xargs docker rmi
Commands
$ docker run --name -it
$ docker run -td --net
$ docker ps -a
$ docker exec -it bash
# System to erase collectively
$ docker rm $(docker ps -aq)
$ docker rm $(docker ps -aq --filter name=)
Example
# MySQL With Password
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:latest
$ do exec -it some-mysql bash
# MySQL Without Password
$ docker run --name some-mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql:latest
Commands
$ docker volume create --name
$ docker volume ls
$ docker volume rm
# System to erase collectively
$ docker volume rm $(docker volume ls --filter name= -q)
$ docker volume rm $(docker volume ls -f dangling=true -q)
Example
# MySQL
$ docker volume create --name hoge
$ docker run --name piyo -d -v hoge:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=pw mysql
$ docker exec -it piyo bash
Frequently Asked Docker Interview Questions & Answers
$ docker network ls
$ docker network inspect
docker-compose
$ docker-compose build
$ docker-compose up
$ docker-compose --project-name= up -d
$ docker-compose ps
$ docker-compose stop
$ docker-compose start
$ docker-compose -f up
$ docker-compose exec bash
$ docker-compose rm
# Check log
$ docker-compose logs
docker-machine
$ docker-machine create -d virtualbox manager
$ docker-machine create
--driver amazonec2 --amazonec2-region ap-northeast-1 --amazonec2-vpc-id vpc-02c94966
--amazonec2-subnet-id subnet-4bcd853d mochizukitest02
$ ll ~/.docker/machine/machines
$ docker-machine ls
$ docker-machine ip manager
$ docker-machine create -d virtualbox worker
$ docker-machine ssh worker
$ docker swarm join
--token SWMTKN-1-26vtuh7mtfofdxkj721ap6eftvqw2i3dsd7yrp5vlsft2t2xzu-8sjf8e5z1aojs3l4htw3r0wg7
192.168.99.100:2377
$ docker info
$ docker-machine stop worker
$ docker-machine start worker
$ docker-machine ip manager
$ docker ssh manager
$ docker swarm init --advertize-addr
$ docker swarm join-token manager
$ docker ssh worker
$ docker swarm join
--token SWMTKN-1-1ydb7x3wyc4ong1y08we9smq61672en9z851rkytcbmfwhj282-1hftyp3smd45bm78k0o33fzp1
192.168.99.103:2377
$ docker node ls
$ docker swarm leave
# stack
$ docker-machine ssh manager
$ docker stack deploy --compose-file docker-stack.yml vote
$ docker stack services vote
Kubernetes Administration |
OpenShift |
Docker Kubernetes |
OpenShift Administration |
Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
Name | Dates | |
---|---|---|
Docker Training | Dec 24 to Jan 08 | View Details |
Docker Training | Dec 28 to Jan 12 | View Details |
Docker Training | Dec 31 to Jan 15 | View Details |
Docker Training | Jan 04 to Jan 19 | View Details |
Vinod M is a Big data expert writer at Mindmajix and contributes in-depth articles on various Big Data Technologies. He also has experience in writing for Docker, Hadoop, Microservices, Commvault, and few BI tools. You can be in touch with him via LinkedIn and Twitter.