{"id":184,"date":"2020-03-29T06:58:32","date_gmt":"2020-03-29T06:58:32","guid":{"rendered":"http:\/\/shresthabrijan.com.np\/?p=184"},"modified":"2020-03-29T08:07:20","modified_gmt":"2020-03-29T08:07:20","slug":"docker-basics","status":"publish","type":"post","link":"https:\/\/shresthabrijan.com.np\/?p=184","title":{"rendered":"Docker basics"},"content":{"rendered":"\n<p>Docker has established itself as a key player in the IT world with many companies adopting it in the production environment. I will go through some docker commands that will be handy while using the service.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker\n\nOnce docker is successfully installed and setup, this command will list available options and command you can use in combination to interact with docker engine<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker version\n\nThis command lists installed version of client and server docker engine in the system<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker info\n\nThis command shows various information related to the docker installation<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker login\n\nLogin into docker registry to push\/pull images<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker image ls\n\nList all the downloaded images<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker ps\n\nList running containers\n\n$docker ps -a\n\nList all the containers including stopped ones\n\n$docker ps -l\n\nList last exited container<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker run\n\nStart a container.\nE.g.\n$docker run -it --rm -p &lt;hostport&gt;:&lt;containerport&gt; --name &lt;containername&gt; &lt;imagename&gt;:&lt;tag&gt; &lt;shell&gt; -c &lt;command 1;command 2&gt;\n\nAbove command starts a container with provided name using image with specified tag. It also starts given shell after the container starts and runs given commands. The --rm flag deletes the container once it is exited. The -p flag maps host port to the container port. If the host port is not given, docker uses a random port.<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker attach\n\nConnect to a running container\nUsage:\n$docker attach &lt;containerID\/Name&gt;<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker exec\n\nRun a new command in a running container<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker logs\n\nView logs of a container<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker kill\n\nKill one or more container<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker rm\n\nRemove one or more containers<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker network\n\nManage networks used by containers\n\n$docker network create\n\nCreate a new network\n\n$docker network connect\n\nConnect a container to a network\nUsage:\n$docker network connect &lt;network_name&gt; &lt;container_name&gt;\n\n$docker network disconnect\n\nDisconnect a network from a container\n\n$docker network ls\n\nList all networks\n\n$docker network prune\n\nDelete all unused networks\n\n$docker network rm\n\nRemove one or more networks<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker commit\n\nCreate a new image from a container\nUsage:\n$docker commit &lt;container ID\/Name&gt; &lt;ImageName&gt;:&lt;Tag&gt; \n\nIf the tag is not provided, docker uses latest as default tag.<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker tag \n\nCreate a new image or update the tag of an existing image<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker pull\n\nPull an image from docker registry<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker push\n\nPush an image to docker registry<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$docker rmi\n\nRemove and\/or untag image<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>For more detail information, visit docker&#8217;s official <a href=\"https:\/\/docs.docker.com\/\">documentation page<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker has established itself as a key player in the IT world with many companies adopting it in the production environment. I will go through some docker commands that will be handy while using the service. $docker Once docker is successfully installed and setup, this command will list available options and command you can use [&hellip;]<\/p>\n<div class=\"read-more\"><a href=\"https:\/\/shresthabrijan.com.np\/?p=184\" class=\"btn btn-primary btn-lg\">Read More<\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-184","post","type-post","status-publish","format-standard","hentry","category-system-administration"],"_links":{"self":[{"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=184"}],"version-history":[{"count":10,"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":196,"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions\/196"}],"wp:attachment":[{"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shresthabrijan.com.np\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}