{"id":2041,"date":"2019-10-31T06:10:51","date_gmt":"2019-10-31T03:10:51","guid":{"rendered":"http:\/\/kusuaks7\/?p=1646"},"modified":"2024-03-06T10:18:49","modified_gmt":"2024-03-06T10:18:49","slug":"fifteen-docker-commands-you-should-know","status":"publish","type":"post","link":"https:\/\/www.experfy.com\/blog\/bigdata-cloud\/fifteen-docker-commands-you-should-know\/","title":{"rendered":"Fifteen Docker Commands You Should Know"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"2041\" class=\"elementor elementor-2041\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"has_eae_slider elementor-section elementor-top-section elementor-element elementor-element-3ce6da47 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3ce6da47\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"has_eae_slider elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6ef2547f\" data-id=\"6ef2547f\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-205d5cf elementor-widget elementor-widget-heading\" data-id=\"205d5cf\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\"><h3 style=\"color: #aaa;font-style: italic\"><strong>Part 5 of\u00a0<em>Learn Enough Docker to be Useful<\/em><\/strong><\/h3><\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6164440 elementor-widget elementor-widget-text-editor\" data-id=\"6164440\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tDocker to be Useful<\/em><\/strong><\/h3>\nIn this article, we\u2019ll look at 15 Docker CLI commands you should know. If you haven\u2019t yet, check out the rest of this series on\u00a0Docker <a href=\"https:\/\/www.experfy.com\/blog\/learn-enough-docker-to-be-useful-part1-the-conceptual-landscape\">concepts<\/a>, the Docker <a href=\"https:\/\/www.experfy.com\/blog\/learn-enough-docker-to-be-useful-part-2-a-delicious-dozen-docker-terms-you-need-to-know\">ecosystems<\/a>, <a href=\"https:\/\/www.experfy.com\/blog\/learn-enough-docker-to-be-useful-part-3-a-dozen-dandy-dockerfile-instructions\">Dockerfiles<\/a>, <a href=\"https:\/\/www.experfy.com\/blog\/slimming-down-your-docker-images-part-4-of-learn-enough-docker-to-be-useful\">slimming down images<\/a>.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-860f72a elementor-widget elementor-widget-text-editor\" data-id=\"860f72a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\nThere are about a billion Docker commands (give or take a billion). The\u00a0<a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/cli\/\" target=\"_blank\" rel=\"noopener noreferrer\">Docker docs<\/a>\u00a0are extensive, but overwhelming when you\u2019re just getting started. In this article, I\u2019ll highlight the key commands for running vanilla Docker.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-922776e elementor-widget elementor-widget-text-editor\" data-id=\"922776e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tAt risk of taking the food metaphor thread running through these articles too far, let\u2019s use a fruit theme. Veggies provided sustenance in the\u00a0<a href=\"https:\/\/www.experfy.com\/blog\/slimming-down-your-docker-images-part-4-of-learn-enough-docker-to-be-useful\">article on slimming down our images<\/a>. Now tasty fruits will give us nutrients as we learn our key Docker commands.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4a2c7ab elementor-widget elementor-widget-heading\" data-id=\"4a2c7ab\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\"><h1 id=\"a230\" data-selectable-paragraph=\"\">Overview<\/h1><\/h1>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ed85f86 elementor-widget elementor-widget-text-editor\" data-id=\"ed85f86\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"6853\" data-selectable-paragraph=\"\">Recall that a Docker image is made of a Dockerfile + any necessary dependencies. Also recall that a Docker container is a Docker image brought to life. To work with Docker commands, you first need to know whether you\u2019re dealing with an image or a container.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-df2e0cf elementor-widget elementor-widget-text-editor\" data-id=\"df2e0cf\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ul>\n \t<li id=\"74e4\" data-selectable-paragraph=\"\"><strong>A Docker image either exists or it doesn\u2019t.<\/strong><\/li>\n \t<li id=\"7c9a\" data-selectable-paragraph=\"\"><strong>A Docker container either exists or it doesn\u2019t.<\/strong><\/li>\n \t<li id=\"b7f2\" data-selectable-paragraph=\"\"><strong>A Docker container that exists is either running or it isn\u2019t.<\/strong><\/li>\n<\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f5c0d78 elementor-widget elementor-widget-text-editor\" data-id=\"f5c0d78\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"0635\" data-selectable-paragraph=\"\">Once you know what you\u2019re working with you can find the right command for the job.<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2e8dfe0 elementor-widget elementor-widget-heading\" data-id=\"2e8dfe0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"1ab6\" data-selectable-paragraph=\"\">Commmand Commonalities<\/h2>\n<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-699efb6 elementor-widget elementor-widget-text-editor\" data-id=\"699efb6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"94ce\" data-selectable-paragraph=\"\">Here are a few things to know about Docker commands:<\/p>\n\n<ul>\n \t<li id=\"fd62\" data-selectable-paragraph=\"\">Docker CLI management commands start with\u00a0<code>docker<\/code>, then a space, then the management category, then a space, and then the command. For example,\u00a0<code>docker container stop<\/code>\u00a0stops a container.<\/li>\n \t<li id=\"826c\" data-selectable-paragraph=\"\">A command referring to a specific container or image requires the name or id of that container or image.<\/li>\n<\/ul>\n<p id=\"0198\" data-selectable-paragraph=\"\">For example,\u00a0<code>docker container run my_app<\/code>\u00a0is the command to build and run the container named\u00a0<em>my_app<\/em>. I\u2019ll use the name\u00a0<code>my_container<\/code>\u00a0to refer to a generic container throughout the examples. Same goes for\u00a0<code>my_image<\/code>,\u00a0<code>my_tag<\/code>, etc.<\/p>\n<p id=\"6327\" data-selectable-paragraph=\"\">I\u2019ll provide the command alone and then with common flags, if applicable. A flag with two dashes in front is the full name of the flag. A flag with one dash is a shortcut for the full flag name. For example,\u00a0<code>-p<\/code>\u00a0is short for the\u00a0<code>--port<\/code>\u00a0flag.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e567094 elementor-widget elementor-widget-image\" data-id=\"e567094\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/640\/1*GXCbJUG6G2EgcUAA4oxX2Q.png\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"has_eae_slider elementor-section elementor-top-section elementor-element elementor-element-d3c2293 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"d3c2293\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"has_eae_slider elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-fad01da\" data-id=\"fad01da\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-704d74c elementor-widget elementor-widget-text-editor\" data-id=\"704d74c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"text-align: center;\" data-selectable-paragraph=\"\"><span style=\"font-size: 11px;\">Flags provide options to commands<\/span><\/p>\n<p id=\"fd74\" data-selectable-paragraph=\"\">The goal is to help these commands and flags stick in your memory and for this guide to serve as a reference. This guide is current for Linux and Docker Engine Version 18.09.1 and API\u00a0<a href=\"https:\/\/docs.docker.com\/engine\/api\/version-history\/\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"broken_link\">version 1.39<\/a>.<\/p>\n<p id=\"3d0c\" data-selectable-paragraph=\"\">First, we\u2019ll look at commands for containers and then we\u2019ll look at commands for images. Volumes will be covered in the next article. Here\u2019s the list of 15 commands to know \u2014 plus 3 bonus commands!<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-19bcd2d elementor-widget elementor-widget-heading\" data-id=\"19bcd2d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"27f3\" data-selectable-paragraph=\"\">Containers<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-327dca4 elementor-widget elementor-widget-text-editor\" data-id=\"327dca4\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"5de2\" data-selectable-paragraph=\"\">Use\u00a0<code>docker container my_command<\/code><\/p>\n<p id=\"df7e\" data-selectable-paragraph=\"\"><code>create<\/code>\u00a0\u2014 Create a container from an image.\n<code>start\u00a0<\/code>\u2014 Start an existing container.\n<code>run<\/code>\u00a0\u2014 Create a new container and start it.\n<code>ls<\/code>\u00a0\u2014 List running<em>\u00a0<\/em>containers.\n<code>inspect<\/code>\u00a0\u2014 See lots of info about a container.\n<code>logs<\/code>\u00a0\u2014 Print logs.\n<code>stop<\/code>\u00a0\u2014 Gracefully stop running container.\n<code>kill<\/code>\u00a0\u2014Stop main process in container abruptly.\n<code>rm<\/code>\u2014 Delete a stopped container.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f5b788d elementor-widget elementor-widget-heading\" data-id=\"f5b788d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"3884\" data-selectable-paragraph=\"\">Images<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-186fabb elementor-widget elementor-widget-text-editor\" data-id=\"186fabb\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"4d55\" data-selectable-paragraph=\"\">Use\u00a0<code>docker image my_command<\/code><\/p>\n<p id=\"9832\" data-selectable-paragraph=\"\"><code>build\u00a0<\/code>\u2014 Build an image.\n<code>push<\/code>\u00a0\u2014 Push an image to a remote registry.\n<code>ls<\/code>\u00a0\u2014 List images.\n<code>history<\/code>\u00a0\u2014 See intermediate image info.\n<code>inspect<\/code>\u00a0\u2014 See lots of info about an image, including the layers.\n<code>rm<\/code>\u00a0\u2014 Delete an image.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6b496d0 elementor-widget elementor-widget-heading\" data-id=\"6b496d0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"f265\" data-selectable-paragraph=\"\">Misc<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-78dbee1 elementor-widget elementor-widget-text-editor\" data-id=\"78dbee1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"7d4c\" data-selectable-paragraph=\"\"><code>docker version<\/code>\u00a0\u2014 List info about your Docker Client and Server versions.\n<code>docker login\u00a0<\/code>\u2014 Log in to a Docker registry.\n<code>docker system prune<\/code>\u00a0\u2014 Delete all unused containers, unused networks, and dangling images.<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1826d01 elementor-widget elementor-widget-heading\" data-id=\"1826d01\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\"><h1 id=\"a068\" data-selectable-paragraph=\"\">Containers<\/h1><\/h1>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-87e58c3 elementor-widget elementor-widget-heading\" data-id=\"87e58c3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"fda9\" data-selectable-paragraph=\"\">Container Beginnings<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5b40178 elementor-widget elementor-widget-text-editor\" data-id=\"5b40178\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"7aad\" data-selectable-paragraph=\"\">The terms create, start, and run all have similar semantics in everyday life. But each is a separate Docker command that creates and\/or starts a container. Let\u2019s look at creating a container first.<\/p>\n<p id=\"305f\" data-selectable-paragraph=\"\"><code><strong>docker container create my_repo\/my_image:my_tag<\/strong><\/code>\u00a0\u2014 Create a container from an image.<\/p>\n<p id=\"c599\" data-selectable-paragraph=\"\">I\u2019ll shorten\u00a0<code>my_repo\/my_image:my_tag<\/code><strong>\u00a0<\/strong>to\u00a0<code>my_image<\/code>\u00a0for the rest of the article.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fb5ad5a elementor-widget elementor-widget-text-editor\" data-id=\"fb5ad5a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"2b6e\" data-selectable-paragraph=\"\">There are\u00a0<a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/create\/#parent-command\" target=\"_blank\" rel=\"noopener noreferrer\">a lot of possible flags<\/a>\u00a0you could pass to\u00a0<code>create<\/code>.<\/p>\n<p id=\"0336\" data-selectable-paragraph=\"\"><code><strong>docker container create -a STDIN my_image<\/strong><\/code><\/p>\n<p id=\"ebf0\" data-selectable-paragraph=\"\"><code>-a<\/code>\u00a0is short for\u00a0<code>--attach<\/code>. Attach the container to STDIN, STDOUT or STDERR.<\/p>\n<p id=\"013c\" data-selectable-paragraph=\"\">Now that we\u2019ve created a container let\u2019s start it.<\/p>\n<p id=\"b734\" data-selectable-paragraph=\"\"><code><strong>docker container start my_container<\/strong><\/code>\u00a0\u2014 Start an existing container.<\/p>\n<p id=\"9a3b\" data-selectable-paragraph=\"\">Note that the container can be referred to by either the container\u2019s ID or the container\u2019s name.<\/p>\n<p id=\"df41\" data-selectable-paragraph=\"\"><code><strong>docker container start my_container<\/strong><\/code><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-21a97af elementor-widget elementor-widget-image\" data-id=\"21a97af\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/640\/1*hdLjLfbTWcXQIjgy2D2t0A.jpeg\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d4a2492 elementor-widget elementor-widget-text-editor\" data-id=\"d4a2492\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"text-align: center;\" data-selectable-paragraph=\"\"><span style=\"font-size: 11px;\">Start<\/span><\/p>\n<p id=\"39cf\" data-selectable-paragraph=\"\">Now that you know how to create and start a container, let\u2019s turn to what\u2019s probably the most common Docker command. It combines both\u00a0<code>create<\/code>\u00a0and\u00a0<code>start<\/code>\u00a0into one command:\u00a0<code>run<\/code>.<\/p>\n<p id=\"a6a0\" data-selectable-paragraph=\"\"><code><strong>docker container run my_image<\/strong><\/code><strong>\u00a0<\/strong>\u2014<strong>\u00a0<\/strong>Create a new container and start it. It also has\u00a0<a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/run\/#parent-command\" target=\"_blank\" rel=\"noopener noreferrer\">a lot of options<\/a>. Let\u2019s look at a few.<\/p>\n<p id=\"7a12\" data-selectable-paragraph=\"\"><code><strong>docker container run -i -t -p 1000:8000 --rm my_image<\/strong><\/code><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-dba32f2 elementor-widget elementor-widget-text-editor\" data-id=\"dba32f2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"484c\" data-selectable-paragraph=\"\"><code>-i<\/code>\u00a0is short for\u00a0<code>--interactive<\/code>. Keep STDIN open even if unattached.<\/p>\n<p id=\"a379\" data-selectable-paragraph=\"\"><code>-t<\/code>is short for<code>--tty<\/code>. Allocates a pseudo\u00a0<a href=\"http:\/\/en.wikipedia.org\/wiki\/Pseudo_terminal\" target=\"_blank\" rel=\"noopener noreferrer\">terminal<\/a>\u00a0that connects your terminal with the container\u2019s STDIN and STDOUT.<\/p>\n<p id=\"00bc\" data-selectable-paragraph=\"\"><mark>You need to specify both\u00a0<\/mark><mark><code>-i<\/code><\/mark><mark>\u00a0and\u00a0<\/mark><mark><code>-t<\/code><\/mark><mark>\u00a0to then interact with the container through your terminal shell.<\/mark><\/p>\n<p id=\"7acf\" data-selectable-paragraph=\"\"><code>-p<\/code>\u00a0is short for\u00a0<code>--port<\/code>. The port is the interface with the outside world.<code>1000:8000<\/code>\u00a0maps the Docker port 8000 to port 1000 on your machine. If you had an app that output something to the browser you could then navigate your browser to\u00a0<code>www.experfy.com:1000<\/code>\u00a0and see it.<\/p>\n<p id=\"a42d\" data-selectable-paragraph=\"\"><code>--rm<\/code>\u00a0Automatically delete the container when it stops running.<\/p>\n<p id=\"0799\" data-selectable-paragraph=\"\">Let\u2019s look at some more examples of\u00a0<code>run<\/code>.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-eb5b57c elementor-widget elementor-widget-text-editor\" data-id=\"eb5b57c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"ebd6\" data-selectable-paragraph=\"\"><code><strong>docker container run -it my_image my_command<\/strong><\/code><\/p>\n<p id=\"ad6c\" data-selectable-paragraph=\"\"><code>sh<\/code>\u00a0is a command you could specify at run time.<code>sh<\/code>\u00a0will start a shell session inside your container that you can interact with through your terminal.\u00a0<code>sh<\/code>\u00a0is preferable to\u00a0<code>bash<\/code>\u00a0for Alpine images because Alpine images don\u2019t come with\u00a0<code>bash<\/code>\u00a0installed. Type\u00a0<code>exit<\/code>\u00a0to end the interactive shell session.<\/p>\n<p id=\"76bd\" data-selectable-paragraph=\"\">Notice that we combined\u00a0<code>-i<\/code>\u00a0and\u00a0<code>-t<\/code>\u00a0into\u00a0<code>-it<\/code>.<\/p>\n<p id=\"8fb7\" data-selectable-paragraph=\"\"><code><strong>docker container run -d my_image<\/strong><\/code><\/p>\n<p id=\"0fcf\" data-selectable-paragraph=\"\"><code>-d<\/code>\u00a0is short for\u00a0<code>--detach<\/code>. Run the container in the background. Allows you to use the terminal for other commands while your container runs.<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-70512a8 elementor-widget elementor-widget-heading\" data-id=\"70512a8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"0082\" data-selectable-paragraph=\"\">Checking Container Status<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6b8c9de elementor-widget elementor-widget-text-editor\" data-id=\"6b8c9de\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"2ec2\" data-selectable-paragraph=\"\">If you have running Docker containers and want to find out which one to interact with, then you need to list them.<\/p>\n<p id=\"2142\" data-selectable-paragraph=\"\"><code><strong>docker container ls<\/strong><\/code>\u00a0\u2014 List running<em>\u00a0<\/em>containers. Also provides useful information about the containers.<\/p>\n<p id=\"5fd2\" data-selectable-paragraph=\"\"><code><strong>docker container ls -a -s<\/strong><\/code><\/p>\n<p id=\"cc63\" data-selectable-paragraph=\"\"><code>-a<\/code>\u00a0is short for\u00a0<code>-all<\/code>. List all containers (not just running ones).<\/p>\n<p id=\"cc8e\" data-selectable-paragraph=\"\"><code>-s<\/code>\u00a0is short for\u00a0<code>--size<\/code>. List the size for each container.<\/p>\n<p id=\"55fa\" data-selectable-paragraph=\"\"><code><strong>docker container inspect my_container<\/strong><\/code>\u00a0\u2014 See lots of info about a container.<\/p>\n<p id=\"2e0f\" data-selectable-paragraph=\"\"><code><strong>docker container logs my_container<\/strong><\/code>\u00a0\u2014 Print a container\u2019s logs.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fb238b1 elementor-widget elementor-widget-image\" data-id=\"fb238b1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/640\/1*icdqfkCNhA8mhJ82ctt54Q.jpeg\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c7c7f8d elementor-widget elementor-widget-text-editor\" data-id=\"c7c7f8d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"text-align: center;\" data-selectable-paragraph=\"\"><span style=\"font-size: 11px;\">Logs. Not sure how virtual logs are related. Maybe via reams of paper?<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-803fe18 elementor-widget elementor-widget-heading\" data-id=\"803fe18\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"323a\" data-selectable-paragraph=\"\">Container Endings<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ea8a0d5 elementor-widget elementor-widget-text-editor\" data-id=\"ea8a0d5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"f6da\" data-selectable-paragraph=\"\">Sometimes you need to stop a running container.<\/p>\n<p id=\"3699\" data-selectable-paragraph=\"\"><code><strong>docker container stop my_container<\/strong><\/code>\u00a0\u2014 Stop one or more running containers gracefully. Gives a default of 10 seconds before container shutdown to finish any processes.<\/p>\n<p id=\"3a1c\" data-selectable-paragraph=\"\">Or if you are impatient:<\/p>\n<p id=\"7c7d\" data-selectable-paragraph=\"\"><code><strong>docker container kill my_container<\/strong><\/code>\u00a0\u2014 Stop one or more running containers abruptly. It\u2019s like pulling the plug on the TV. Prefer\u00a0<code>stop<\/code>\u00a0in most situations.<\/p>\n<p id=\"e4fc\" data-selectable-paragraph=\"\"><code>d<strong>ocker container kill $(docker ps -q)<\/strong><\/code>\u00a0\u2014 Kill all running containers.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2d2c528 elementor-widget elementor-widget-image\" data-id=\"2d2c528\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/640\/1*z04O3uNyI_so53j0hqIjhg.jpeg\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-88f823f elementor-widget elementor-widget-text-editor\" data-id=\"88f823f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"text-align: center;\" data-selectable-paragraph=\"\"><span style=\"font-size: 11px;\">docker kill cockroach<\/span><\/p>\n<p id=\"a036\" data-selectable-paragraph=\"\">Then you delete the container with:<\/p>\n<p id=\"706a\" data-selectable-paragraph=\"\"><code><strong>docker container rm my_container<\/strong><\/code>\u00a0\u2014 Delete one or more containers.<\/p>\n<p id=\"e472\" data-selectable-paragraph=\"\"><code><strong>docker container rm $(docker ps -a -q)<\/strong><\/code>\u00a0\u2014 Delete all containers that are not running.<\/p>\n<p id=\"20e1\" data-selectable-paragraph=\"\">Those are the eight essential commands for Docker containers.<\/p>\n<p id=\"e6c7\" data-selectable-paragraph=\"\">To recap, you first create a container. Then, you start the container. Or combine those steps with\u00a0<code>docker run my_container<\/code>. Then, your app runs. Yippee!<\/p>\n<p id=\"a07a\" data-selectable-paragraph=\"\">Then, you stop a container with\u00a0<code>docker stop my_container<\/code>. Eventually you delete the container with\u00a0<code>docker rm my_container<\/code>.<\/p>\n<p id=\"8cfb\" data-selectable-paragraph=\"\">Now, let\u2019s turn to the magical container-producing molds called images.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f643521 elementor-widget elementor-widget-heading\" data-id=\"f643521\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\"><h1 id=\"33fe\" data-selectable-paragraph=\"\">Images<\/h1><\/h1>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ebffdf2 elementor-widget elementor-widget-text-editor\" data-id=\"ebffdf2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"d40b\" data-selectable-paragraph=\"\">Here are seven commands for working with Docker images.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f1917fd elementor-widget elementor-widget-heading\" data-id=\"f1917fd\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"6290\" data-selectable-paragraph=\"\">Developing Images<\/h2>\n<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f3c651d elementor-widget elementor-widget-text-editor\" data-id=\"f3c651d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"05ae\" data-selectable-paragraph=\"\"><code><strong>docker image build -t my_repo\/my_image:my_tag .<\/strong><\/code>\u00a0\u2014 Build a Docker image named\u00a0<em>my_image<\/em>\u00a0from the Dockerfile located at the specified path or URL.<\/p>\n<p id=\"fe66\" data-selectable-paragraph=\"\"><code>-t<\/code>\u00a0is short for tag. Tells docker to tag the image with the provided tag. In this case\u00a0<em>my_tag .<\/em><\/p>\n<p id=\"29dc\" data-selectable-paragraph=\"\">The\u00a0<code>.<\/code>\u00a0(period) at the end of the command tells Docker to build the image according to the Dockerfile in the current working directory.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0b9b221 elementor-widget elementor-widget-image\" data-id=\"0b9b221\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/640\/1*pzypY32qru9mOB-qOb4Evw.jpeg\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-41434e0 elementor-widget elementor-widget-text-editor\" data-id=\"41434e0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"text-align: center;\" data-selectable-paragraph=\"\"><span style=\"font-size: 11px;\">Build it<\/span><\/p>\n<p id=\"7c30\" data-selectable-paragraph=\"\">Once you have an image built you want to\u00a0<code>push<\/code>\u00a0it to a remote registry so it can be shared and pulled down as needed. Assuming you want to use\u00a0<a href=\"https:\/\/hub.docker.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Docker Hub<\/a>, go there in your browser and create an account. It\u2019s free.<\/p>\n<p id=\"2f3a\" data-selectable-paragraph=\"\">This next command isn\u2019t an image command, but it\u2019s useful to see here, so I\u2019ll mention it.<\/p>\n<p id=\"e908\" data-selectable-paragraph=\"\"><code><strong>docker login<\/strong><\/code>\u00a0\u2014 Log in to a Docker registry. Enter your username and password when prompted.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2bf889b elementor-widget elementor-widget-image\" data-id=\"2bf889b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/640\/1*ZgMR-_PYuu3ghNyPzLHrGA.jpeg\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b492d35 elementor-widget elementor-widget-text-editor\" data-id=\"b492d35\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"text-align: center;\" data-selectable-paragraph=\"\"><span style=\"font-size: 11px;\">Push<\/span><\/p>\n<p id=\"834d\" data-selectable-paragraph=\"\"><code><strong>docker image push my_repo\/my_image:my_tag<\/strong><\/code>\u00a0\u2014 Push an image to a registry.<\/p>\n<p id=\"ae02\" data-selectable-paragraph=\"\">Once you have some images you might want to inspect them.<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-47549ef elementor-widget elementor-widget-heading\" data-id=\"47549ef\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"dcae\" data-selectable-paragraph=\"\">Inspecting Images<\/h2>\n<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9f15fe5 elementor-widget elementor-widget-image\" data-id=\"9f15fe5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/640\/1*ZgMR-_PYuu3ghNyPzLHrGA.jpeg\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8c4774b elementor-widget elementor-widget-text-editor\" data-id=\"8c4774b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"text-align: center;\" data-selectable-paragraph=\"\"><span style=\"font-size: 11px;\">Inspection time<\/span><\/p>\n<p id=\"241d\" data-selectable-paragraph=\"\"><code><strong>docker image ls<\/strong><\/code>\u00a0\u2014 List your images. Shows you the size of each image, too.<\/p>\n<p id=\"7cc8\" data-selectable-paragraph=\"\"><code><strong>docker image history my_image<\/strong><\/code>\u00a0\u2014 Display an image\u2019s intermediate images with sizes and how they were created.<\/p>\n<p id=\"adb7\" data-selectable-paragraph=\"\"><code><strong>docker image inspect my_image<\/strong><\/code>\u00a0\u2014 Show lots of details about your image, including the layers that make up the image.<\/p>\n<p id=\"be7d\" data-selectable-paragraph=\"\">Sometimes you\u2019ll need to clean up your images.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-586cccc elementor-widget elementor-widget-heading\" data-id=\"586cccc\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"269e\" data-selectable-paragraph=\"\">Removing Images<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ba4a6ed elementor-widget elementor-widget-text-editor\" data-id=\"ba4a6ed\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"43fa\" data-selectable-paragraph=\"\"><code><strong>docker image rm my_image<\/strong><\/code>\u00a0\u2014 Delete the specified image. If the image is stored in a remote repository, the image will still be available there.<\/p>\n<p id=\"7e5e\" data-selectable-paragraph=\"\"><code><strong>docker image rm $(docker images -a -q)<\/strong><\/code>\u00a0\u2014 Delete all images. Careful with this one! Note that images that have been pushed to a remote registry will be preserved \u2014 that\u2019s one of the benefits of registries.<\/p>\n<p id=\"5fb4\" data-selectable-paragraph=\"\">Now you know most essential Docker image-related commands. We\u2019ll cover data-related commands in the next article.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a7f3468 elementor-widget elementor-widget-heading\" data-id=\"a7f3468\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h1 id=\"5cee\" data-selectable-paragraph=\"\">Misc<\/h1><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e0a50ff elementor-widget elementor-widget-text-editor\" data-id=\"e0a50ff\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"b1a3\" data-selectable-paragraph=\"\"><code><strong>docker version<\/strong><\/code>\u00a0\u2014 List info about your Docker Client and Server versions.<\/p>\n<p id=\"7c0c\" data-selectable-paragraph=\"\"><code><strong>docker login<\/strong><\/code>\u2014 Log in to a Docker registry. Enter your username and password when prompted.<\/p>\n<p id=\"7f05\" data-selectable-paragraph=\"\"><code><strong>docker system prune<\/strong><\/code>\u00a0makes an appearance in the next article. Readers on\u00a0<a href=\"https:\/\/twitter.com\/Docker\/status\/1093233051906134016\" target=\"_blank\" rel=\"noopener noreferrer\">Twitter<\/a>\u00a0and\u00a0<a href=\"https:\/\/www.reddit.com\/r\/docker\/comments\/anh1se\/15_docker_commands_you_should_know_part_5_of\/\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"broken_link\">Reddit<\/a>\u00a0suggested that it would be good to add to this list. I agree, so I\u2019m adding it.<\/p>\n<p id=\"c1de\" data-selectable-paragraph=\"\"><code><strong>docker system prune<\/strong><\/code>\u00a0\u2014Delete all unused containers, unused networks, and dangling images.<\/p>\n<p id=\"3fa1\" data-selectable-paragraph=\"\"><code><strong>docker system prune -a --volumes<\/strong><\/code><\/p>\n<p id=\"f22d\" data-selectable-paragraph=\"\"><code>-a<\/code>\u00a0is short for\u00a0<code>--all<\/code>. Delete unused images,\u00a0<a href=\"https:\/\/stackoverflow.com\/a\/45143234\/4590385\" target=\"_blank\" rel=\"noopener noreferrer\">not just dangling ones<\/a>.<\/p>\n<p id=\"ddfe\" data-selectable-paragraph=\"\"><code>--volumes<\/code>\u00a0Remove unused volumes. We\u2019ll talk more about volumes in the next article.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e718cf4 elementor-widget elementor-widget-heading\" data-id=\"e718cf4\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"c44c\" data-selectable-paragraph=\"\">UPDATE Feb. 7, 2019: Management Commands<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9033012 elementor-widget elementor-widget-text-editor\" data-id=\"9033012\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"3809\" data-selectable-paragraph=\"\">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\u2019ve updated the article to use the management command names based on reader suggestions. Note that this change only introduces two command name changes \u2014 in most cases it just means adding\u00a0<code>container<\/code>\u00a0or\u00a0<code>image<\/code>\u00a0to the command. A mapping of the commands is\u00a0<a href=\"http:\/\/blog.arungupta.me\/docker-1-13-management-commands\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ac7bc5b elementor-widget elementor-widget-heading\" data-id=\"ac7bc5b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\"><h1 id=\"ca9c\" data-selectable-paragraph=\"\">Wrap<\/h1><\/h1>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f8aaf58 elementor-widget elementor-widget-text-editor\" data-id=\"f8aaf58\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"4d6b\" data-selectable-paragraph=\"\">If you are just getting started with Docker, these are the three most important commands:<\/p>\n<p id=\"d0a2\" data-selectable-paragraph=\"\"><code><strong>docker container run my_image<\/strong><\/code>\u00a0\u2014 Create a new container and start it. You\u2019ll probably want some flags here.<\/p>\n<p id=\"412f\" data-selectable-paragraph=\"\"><code><strong>docker image build -t my_repo\/my_image:my_tag .<\/strong><\/code>\u00a0\u2014 Build an image.<\/p>\n<p id=\"80f6\" data-selectable-paragraph=\"\"><code><strong>docker image push my_repo\/my_image:my_tag<\/strong><\/code>\u00a0\u2014 Push an image to a remote registry.<\/p>\n<p id=\"5b7b\" data-selectable-paragraph=\"\">Here\u2019s the larger list of essential Docker commands:<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bb3401d elementor-widget elementor-widget-heading\" data-id=\"bb3401d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"ae9d\" data-selectable-paragraph=\"\">Containers<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-24010cc elementor-widget elementor-widget-text-editor\" data-id=\"24010cc\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"6490\" data-selectable-paragraph=\"\">Use\u00a0<code>docker container my_command<\/code><\/p>\n<p id=\"1901\" data-selectable-paragraph=\"\"><code>create<\/code>\u00a0\u2014 Create a container from an image.\n<code>start\u00a0<\/code>\u2014 Start an existing container.\n<code>run<\/code>\u00a0\u2014 Create a new container and start it.\n<code>ls<\/code>\u00a0\u2014 List running<em>\u00a0<\/em>containers.\n<code>inspect<\/code>\u00a0\u2014 See lots of info about a container.\n<code>logs<\/code>\u00a0\u2014 Print logs.\n<code>stop<\/code>\u00a0\u2014 Gracefully stop running container.\n<code>kill<\/code>\u00a0\u2014Stop main process in container abruptly.\n<code>rm<\/code>\u2014 Delete a stopped container.<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1fb3c10 elementor-widget elementor-widget-heading\" data-id=\"1fb3c10\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"cdd7\" data-selectable-paragraph=\"\">Images<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-485776e elementor-widget elementor-widget-text-editor\" data-id=\"485776e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"0f8f\" data-selectable-paragraph=\"\">Use\u00a0<code>docker image my_command<\/code><\/p>\n<p id=\"1ae7\" data-selectable-paragraph=\"\"><code>build\u00a0<\/code>\u2014 Build an image.\n<code>push<\/code>\u00a0\u2014 Push an image to a remote registry.\n<code>ls<\/code>\u00a0\u2014 List images.\n<code>history<\/code>\u00a0\u2014 See intermediate image info.\n<code>inspect<\/code>\u00a0\u2014 See lots of info about an image, including the layers.\n<code>rm<\/code>\u00a0\u2014 Delete an image.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-53f6160 elementor-widget elementor-widget-heading\" data-id=\"53f6160\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"611b\" data-selectable-paragraph=\"\">Misc<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e6ba49f elementor-widget elementor-widget-text-editor\" data-id=\"e6ba49f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p id=\"5d3a\" data-selectable-paragraph=\"\"><code>docker version<\/code>\u00a0\u2014 List info about your Docker Client and Server versions.\n<code>docker login\u00a0<\/code>\u2014 Log in to a Docker registry.\n<code>docker system prune<\/code>\u00a0\u2014 Delete all unused containers, unused networks, and dangling images.<\/p>\n<p id=\"caef\" data-selectable-paragraph=\"\">To view the CLI reference when using Docker just enter the command\u00a0<code>docker<\/code>\u00a0in the command line. You can see the Docker docs\u00a0<a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/cli\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<p id=\"b670\" data-selectable-paragraph=\"\">Now you can really build things with Docker!<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Recall that a Docker image is made of a Dockerfile + any necessary dependencies. Also recall that a Docker container is a Docker image brought to life. To work with Docker commands, you first need to know whether you&rsquo;re dealing with an image or a container. Once you know what you&rsquo;re working with you can find the right command for the job. This article highlights the key commands for running vanilla Docker. Here are a few things to know about Docker commands.<\/p>\n","protected":false},"author":369,"featured_media":4387,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[187],"tags":[94],"ppma_author":[2134],"class_list":["post-2041","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bigdata-cloud","tag-data-science"],"authors":[{"term_id":2134,"user_id":369,"is_guest":0,"slug":"jeff-hale","display_name":"Jeff Hale","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","user_url":"","last_name":"Hale","first_name":"Jeff","job_title":"","description":"Jeff Hale is a co-founder of Rebel Desk, where he oversees technology, finance, and operations for this company. He&nbsp;is an experienced entrepreneur who has managed technology, operations, and finances for several companies.&nbsp;"}],"_links":{"self":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/2041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/users\/369"}],"replies":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/comments?post=2041"}],"version-history":[{"count":6,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/2041\/revisions"}],"predecessor-version":[{"id":36263,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/2041\/revisions\/36263"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media\/4387"}],"wp:attachment":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media?parent=2041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/categories?post=2041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/tags?post=2041"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=2041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}