{"componentChunkName":"component---src-templates-post-js","path":"/pensieve/docker-basics-cheatsheet-2mm4","result":{"data":{"markdownRemark":{"html":"<p><img src=\"https://3kllhk1ibq34qk6sp3bhtox1-wpengine.netdna-ssl.com/wp-content/uploads/2017/01/how-to-deploy-java-apps-with-docker-a-quick-tutorial@3x-1560x760.png\" alt=\"Draft fail\"></p>\n<h3>Create image using this directory's Dockerfile</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\">docker build -t &lt;somename></span></code></pre></div>\n<h3>Run <somename> mapping port 8000</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker run -p 8000:80 &lt;somename></span></code></pre></div>\n<h3>Same thing, but in detached mode</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker run -d -p 8000:80 &lt;somename></span></code></pre></div>\n<h3>Enter a running container (you can also do sh)</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker exec -it [container-id] bash</span></code></pre></div>\n<h3>See a list of all running containers</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker ps</span></code></pre></div>\n<h3>Gracefully stop the specified container</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker stop &lt;hash></span></code></pre></div>\n<h3>See a list of all containers , active and inactive</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker ps -a</span></code></pre></div>\n<h3>Force shutdown of the specified container</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker kill &lt;hash></span></code></pre></div>\n<h3>Remove the specified container from this machine</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker rm &lt;hash></span></code></pre></div>\n<h3>Remove all containers from this machine</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token command\"><span class=\"token info punctuation\"><span class=\"token path\">docker rm </span></span><span class=\"token shell-symbol important\">$</span><span class=\"token bash language-bash\"><span class=\"token punctuation\">(</span>docker <span class=\"token function\">ps</span> -a -q<span class=\"token punctuation\">)</span></span></span></code></pre></div>\n<h3>Show all images on this machine</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\">docker images -a</span></code></pre></div>\n<h3>Remove the specified image from this machine</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\">docker rmi &lt;imagename></span></code></pre></div>\n<h3>Remove all images from this machine</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token command\"><span class=\"token info punctuation\"><span class=\"token path\">docker rmi </span></span><span class=\"token shell-symbol important\">$</span><span class=\"token bash language-bash\"><span class=\"token punctuation\">(</span>docker images -q<span class=\"token punctuation\">)</span></span></span></code></pre></div>\n<h3>Log in this CLI session using your Docker credentials</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker login</span></code></pre></div>\n<h3>Tag <image> for upload to registry</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker tag &lt;image> username/repository:tag</span></code></pre></div>\n<h3>Upload tagged image to registry</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker push username/repository:tag</span></code></pre></div>\n<h3>Run image from a registry</h3>\n<div class=\"gatsby-highlight\" data-language=\"shell-session\"><pre class=\"language-shell-session\"><code class=\"language-shell-session\"><span class=\"token output\"> docker run username/repository:tag</span></code></pre></div>","frontmatter":{"title":"Docker basics/ cheatsheet","description":null,"date":"2019-11-22","slug":"/pensieve/docker-basics-cheatsheet-2mm4","tags":["Docker","Containers","Unix"]}}},"pageContext":{}},"staticQueryHashes":["3115057458"]}