{"id":65,"date":"2019-01-11T23:56:26","date_gmt":"2019-01-11T22:56:26","guid":{"rendered":"http:\/\/mhichri.com\/?p=65"},"modified":"2023-02-10T19:04:55","modified_gmt":"2023-02-10T18:04:55","slug":"docker-useful-commands","status":"publish","type":"post","link":"https:\/\/mhichri.com\/index.php\/2019\/01\/11\/docker-useful-commands\/","title":{"rendered":"Docker useful commands"},"content":{"rendered":"\n<p>Docker ! You must heard of it ! <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.docker.com\/sites\/default\/files\/social\/docker_facebook_share.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Here are some useful commands that you need to master in order to manage containers with docker<\/p>\n\n\n\n<p><strong>docker run &lt;image-name><\/strong>  ==> run a docker container with a specific image. Docker engine will load the image from local image repository, otherwise, it will fetch it from docker hub image repository<br>parameters :<br>-d ==> run container on background<br>-it ==> run container on interactive way (needs to specify a command, such as &#8220;\/bin\/bash&#8221; at the end of the line)<br>&#8211;name ==> give a name to a container<br>-p ==> bind the container port to a specific port in your application<br><br><\/p>\n\n\n\n<p><strong>docker version <\/strong>==> get the docker server and client versions<\/p>\n\n\n\n<p><strong>docker info<\/strong> ==> get information about docker engine (number of running containers, swarm &#8230;)<\/p>\n\n\n\n<p><strong>docker images<\/strong> ==> lists docker images in local repository<\/p>\n\n\n\n<p><strong>docker ps<\/strong> ==> lists running containers<\/p>\n\n\n\n<p><strong>docker ps -a<\/strong> ==> lists all containers (even stopped once)<\/p>\n\n\n\n<p><strong>docker rmi &lt;image-name|image_id> <\/strong>==> remove image from local repository<\/p>\n\n\n\n<p><strong>docker pull &lt;image-name>:&lt;version> <\/strong>==> download docker image (with specific version) from docker hub<br>For instance : docker pull ubuntu:14:04<\/p>\n\n\n\n<p><strong>docker  start &lt;container-id><\/strong> ==> start a container<\/p>\n\n\n\n<p><strong>docker stop &lt;container-id><\/strong> ==> stop a container<\/p>\n\n\n\n<p><strong>docker rm &lt;container-id><\/strong> ==> delete a container<\/p>\n\n\n\n<p><strong>docker stop $(docker ps -aq)<\/strong> ==> stop all containers<\/p>\n\n\n\n<p><strong>docker rm $(docker ps -aq) <\/strong>==> delete all stopped containers<\/p>\n\n\n\n<p><strong>docker rmi $(docker images -q) <\/strong>==> delete all images from local repository<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker ! You must heard of it ! Here are some useful commands that you need to master in order to manage containers with docker docker run &lt;image-name> ==> run a docker container with a specific image. Docker engine will load the image from local image repository, otherwise, it will fetch it from docker hub &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/mhichri.com\/index.php\/2019\/01\/11\/docker-useful-commands\/\"> <span class=\"screen-reader-text\">Docker useful commands<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"","footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/posts\/65"}],"collection":[{"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":9,"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":74,"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions\/74"}],"wp:attachment":[{"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mhichri.com\/index.php\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}