Docker Management Commands

 Often I noticed that people used to struggle a bit with the commands when it came to which resource they were dealing with. For e.g. were you working with an image or do you need to give the container id and so on.

As an example, consider the following docker command:

$ docker rm 

When typing these commands, there is often the confusion in the minds of the user if we need to provide an image id or does this apply to container id. Often this resulted in looking up for help which would tell you what was expected, as given below:

$ docker rm
“docker rm” requires at least 1 argument(s).
See ‘docker rm — help’.Usage: docker rm [OPTIONS] CONTAINER [CONTAINER…]Remove one or more containers

This is now addressed in Docker 1.13.0 with the release of Management Commands. If you simply type docker at the terminal, you will see the section on Management Commands as given below:

Management Commands:
checkpoint Manage checkpoints
container Manage containers
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
volume Manage volumes

So if you are dealing with images, you know that you can begin your command logically with

$ docker image <command>

or if you are dealing with containers, it should logically be:

$ docker container <command>

This is good design in my opinion and it is something that I have seen across other Command Line Interfaces (CLI) too, that make you mentally decide which resource you want to manage and then there would be typically commands like listing, adding, removing, monitoring, etc.

Additional comments

  • To see the management commands, ensure that you are running Docker version 1.13.0
  • The Management Commands as well as the older commands work side by side. The older commands have not got removed and most likely won’t due to the 1000s of scripts that might be automated everywhere.
  • There could be a bit of confusion in the commands. To illustrate that, consider the remove command. Prior to Docker 1.13.0 , it was docker rmi for removing images and docker rm for removing containers. Both of these commands are still available. However, if you consider the new management commands, then there is a single command now called ‘rm’. So to remove the images, you would use docker image rm and to remove the containers, you would use docker container rm. This makes perfect sense but could take a bit to getting used to typing, especially if you have spent hours typing and practicing the older commands.

Written by

Leave a Reply

Your email address will not be published. Required fields are marked *