{"id":1890,"date":"2022-03-11T21:55:20","date_gmt":"2022-03-12T04:55:20","guid":{"rendered":"https:\/\/jim-zimmerman.com\/?p=1890"},"modified":"2023-10-02T17:28:01","modified_gmt":"2023-10-03T00:28:01","slug":"docker-commands","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=1890","title":{"rendered":"Docker Commands"},"content":{"rendered":"<p>Run vs exec:<br \/>\n<em>docker exec<\/em> is used to run commands in an already running container.  <em>docker run<\/em> is used to create a new container that can be committed to create an updated container.<\/p>\n<p>Here is how execute commands inside a docker container as root:<\/p>\n<blockquote><p>$ docker exec -u 0 -it runningcontainer bash<\/p><\/blockquote>\n<p>The same concept works for docker run too:<br \/>\nHere is how execute commands inside a docker container as root:<\/p>\n<blockquote><p>$ docker run -u 0 -it dockerimage bash<\/p><\/blockquote>\n<p>This will clean up the \/var\/lib area:<\/p>\n<blockquote><p>docker system prune -a<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Run vs exec: docker exec is used to run commands in an already running container. docker run is used to create a new container that can be committed to create an updated container. Here is how execute commands inside a docker container as root: $ docker exec -u 0 -it runningcontainer bash The same concept [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[494],"class_list":["post-1890","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-docker"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1890"}],"version-history":[{"count":4,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1890\/revisions"}],"predecessor-version":[{"id":1910,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1890\/revisions\/1910"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}