Working with Docker v1.13 CLI -Management commands
In Docker engine v1.13, we got the management commands for container, image, plugin, secret, stack and system.
Below, we’ll see how to work with each of the management commands and sub-commands.
docker container
To attach to a running container
docker container attach <container-id/name>
To create a image from a container’s changes
docker container commit <container-id/name> <new-image-name>
To copy files/folders from the host to a container or vice-versa.
docker container cp <file> <container-id/name>:/path/to/copydocker container cp <container-id/name>:/path/from/copy <to-copy-on-host>
To create a new container
docker container create --name <container-name> <image-id/name>
To inspect changes on a container’s filesystem
docker container diff <container-id/name>
To run a command in a running container
docker container exec <container-id/name>
To export a container’s filesystem as a tar archive
docker container export <container-id/name>
To display low-level information of a container
docker container inspect <container-id/name>
To kill a running container
docker container kill <container-id/name>
To fetch the logs of a container
docker container logs <container-id/name>
To list containers
docker container ls
OR docker container list
OR docker container ps
To pause all processes within a container
docker container pause <container-id/name>
To list port mappings for the container
docker container port <container-id/name>
To remove all stopped containers
docker container prune
To rename a container
docker container rename <old-container-name> <new-container-name>
To restart a container
docker container restart <container-id/name>
To remove a container
docker container rm <container-id/name>
To run a command in a new container
docker container run --name <container-name> -it <image-name>
To start a stopped container
docker container start <container-id/name>
To display a live stream of container(s) resource usage statistics
docker container stats
To stop a container
docker container stop <container-id/name>
To display the running processes of a container
docker container top <container-id/name>
To unpause all processes within a container
docker container unpause <container-id/name>
To update configuration of a container
docker container update <OPTIONS> <container-id/name>
To block until a container stops and then print their exit codes
docker container wait <container-id/name>
docker image
To build an image from a Dockerfile
docker image build -t <image-name> .
To show the history of an image
docker image history <image-id/name>
To import the contents from a tarball to create a filesystem image
docker image import <file-name> <image-name>
To display low-level information of a image
docker image inspect <image-id/name>
To load an image from a tar archive or STDIN
docker image load -i <file-name>
To list images
docker image ls
OR docker image list
OR docker image images
To remove unused images
docker image prune
To pull an image from a registry
docker image pull <image-name:tag>
To push an image to a registry
docker image push <image-name:tag>
To remove a image
docker image rm <image-id/name>
To save an image to a tar archive
docker image save <image-name>
To create a tag for a image
docker image tag <old-image-name> <new-image-name>
docker network
To connect a container to a network
docker network connect <network-name> <container-id/name>
To create a network
docker network create -d <network-driver> <OPTIONS> <network-name>
To disconnect a container from a network
docker network disconnect <network-name> <container-id/name>
To display detailed information of a network
docker network inspect <network-name>
To list networks
docker network ls
To remove all unused networks
docker network prune
To remove a network
docker network rm <network-name>
docker node
To demote a node from manager in the swarm
docker node demote <node-name>
To display detailed information on a node
docker node inspect <node-name>
To list nodes in the swarm
docker node ls
To promote one or more nodes to manager in the swarm
docker node promote <node-name>
To list tasks running on one or more nodes.
docker node ps self/<node-name>
To remove one or more nodes from the swarm
docker node rm <node-name>
To update a node
docker node update <node-name>
docker plugin
To create a plugin from a rootfs and configuration. Plugin data directory must contain config.json and rootfs directory.
docker plugin create <plugin-name> <plugin-data-dir>
To disable a plugin
docker plugin disable <plugin-name>
To enable a plugin
docker plugin enable <plugin-name>
To display detailed information of a plugin
docker plugin inspect <plugin-name>
To install a plugin
docker plugin install <OPTIONS> <plugin-name>
To list plugins
docker plugin ls
OR docker plugin list
To push a plugin to a registry
docker plugin push <plugin-name:tag>
To remove a plugin
docker plugin rm <plugin-name>
To change settings for a plugin
docker plugin set <plugin-name> KEY=VALUE
docker secret
To create a secret from a file or STDIN as content
docker secret create <secret-name> <file-name>
To display detailed information of a secret
docker secret inspect <secret-name>
To list secrets
docker secret ls
OR docker secret list
To remove a secret
docker secret rm <secret-name>
docker service
To create a new service
docker service create <OPTIONS> <image-name> <CMD>
To display detailed information of a service
docker service inspect <service-name>
To list services
docker service ls
OR docker service list
To list the tasks of a service
docker service ps <service-name>
To remove a service
docker service rm <service-name>
To scale one or multiple replicated services
docker service scale <service-name>=<replicas>
To update a servicedoc
docker service update <OPTIONS> <service-name>
docker stack
To deploy a new stack or update an existing stack
docker stack deploy -c <compose-file> <stack-name>
To list stacks
docker stack ls
OR docker stack list
To list the tasks in the stack
docker stack ps <stack-name>
To remove the stack
docker stack rm <stack-name>
To list the services in the stack
docker stack services <stack-name>
docker swarm
To initialize a swarm
docker swarm init <OPTIONS>
To join a swarm as a node and/or manager
docker swarm join <OPTIONS> <HOST>:<PORT>
To manage join tokens
docker swarm join-token <OPTIONS> worker/manager
To leave the swarm
docker swarm leave
To unlock swarm
docker swarm unlock
To manage the unlock key
docker swarm unlock-key
To update the swarm
docker swarm update <OPTIONS>
docker system
To show docker disk usage
docker system df
To get real time events from the server
docker system events
To display system-wide information
docker system info
To remove unused data
docker system prune
docker volume
To create a volume
docker volume create -d <volume-driver-name> <volume-name>
To display detailed information of a volume
docker volume inspect <volume-name>
To list volumes
docker volume ls
To remove all unused volumes
docker volume prune
To remove a volume
docker volume rm <volume-name>
Source: ~ Docker CLI
Disclaimer: Content and image source has been mentioned. Special Credit to concerned folks.