docker version
— List info about your Docker Client and Server versions.
docker login
— Log in to a Docker registry. Enter your username and password when prompted.
docker system prune
makes an appearance in the next article. Readers on Twitter and Reddit suggested that it would be good to add to this list. I agree, so I’m adding it.
docker system prune
—Delete all unused containers, unused networks, and dangling images.
docker system prune -a --volumes
-a
is short for --all
. Delete unused images, not just dangling ones.
--volumes
Remove unused volumes. We’ll talk more about volumes in the next article.
In CLI 1.13 Docker introduced management command names that are logically grouped and consistently named. The old commands still work, but the new ones make it easier to get started with Docker. The original version of this article listed the old names. I’ve updated the article to use the management command names based on reader suggestions. Note that this change only introduces two command name changes — in most cases it just means adding container
or image
to the command. A mapping of the commands is here.
If you are just getting started with Docker, these are the three most important commands:
docker container run my_image
— Create a new container and start it. You’ll probably want some flags here.
docker image build -t my_repo/my_image:my_tag .
— Build an image.
docker image push my_repo/my_image:my_tag
— Push an image to a remote registry.
Here’s the larger list of essential Docker commands:
Use docker container my_command
create
— Create a container from an image. start
— Start an existing container. run
— Create a new container and start it. ls
— List running containers. inspect
— See lots of info about a container.logs
— Print logs. stop
— Gracefully stop running container. kill
—Stop main process in container abruptly. rm
— Delete a stopped container.
Use docker image my_command
build
— Build an image.push
— Push an image to a remote registry.ls
— List images. history
— See intermediate image info.inspect
— See lots of info about an image, including the layers. rm
— Delete an image.
docker version
— List info about your Docker Client and Server versions.docker login
— Log in to a Docker registry.docker system prune
— Delete all unused containers, unused networks, and dangling images.
To view the CLI reference when using Docker just enter the command docker
in the command line. You can see the Docker docs here.
Now you can really build things with Docker! As my daughter might say in emoji: 🍒 🥝 🍊 🍋 🍉 🍏 🍎 🍇. Which I think translates to “Cool!” So go forth and play with Docker!
If you missed the earlier articles in this series, check them out. Here’s the first one:
In the final article in this series we’ll spice things up with a discussion of data in Docker. Follow me to make sure you don’t miss it!
I hope you found this article helpful. If you did, please give it some love on your favorite social media channels. Docker on! 👏