{"id":11803,"date":"2019-03-17T11:38:15","date_gmt":"2019-03-17T11:38:15","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11803"},"modified":"2019-03-17T11:38:15","modified_gmt":"2019-03-17T11:38:15","slug":"how-to-name-or-rename-docker-containers","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/how-to-name-or-rename-docker-containers\/","title":{"rendered":"How to Name or Rename Docker Containers"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/camo.githubusercontent.com\/58f715bc90083504a2e2eca9301a3bc087fb3c9b\/68747470733a2f2f7777772e646f636b65722e636f6d2f73697465732f64656661756c742f66696c65732f696c6c757374726174696f6e2d636f6d2d636f6e7461696e65722d70617274792e706e67\" alt=\"Image result for docker photo\" \/><\/p>\n<p>When Docker containers are created, the system automatically assign a universally unique identifier (<strong>UUID<\/strong>) number to each container to avoid any naming conflicts and improve automation without human involvement.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/install-docker-and-learn-containers-in-centos-rhel-7-6\/\" target=\"_blank\" rel=\"noopener\">How to Install Docker and Learn Basic Container Manipulation in CentOS<\/a><\/p>\n<p>In this article, we will explain how to easily identify Docker containers and name or rename containers in Linux.<\/p>\n<p>By default, docker uses three ways to identify a container, namely:<\/p>\n<ul>\n<li><strong>UUID long identifier<\/strong>\u00a0e.g \u201c<strong>21fbb152a940a37e816a442e6b09022e26b78ccd5a8eb4fcf91efeb559425c8c<\/strong>\u201d.<\/li>\n<li><strong>UUID short identifier<\/strong>\u00a0e.g \u201c<strong>21fbb152a940a37<\/strong>\u201d.<\/li>\n<li><strong>name<\/strong>\u00a0e.g\u00a0<strong>discourse_app<\/strong>.<\/li>\n<\/ul>\n<p>Note that if no name is specified, by default, the the Docker daemon assigns containers a UUID long identifier; it generates a random string as a name.<\/p>\n<h3>How to Name a Docker Container<\/h3>\n<p>You can assign memorable names to your docker containers when you run them, using the\u00a0<code>--name<\/code>\u00a0flag as follows. The\u00a0<code>-d<\/code>\u00a0flag tells docker to run a container in detached mode, in the background and print the new container ID.<\/p>\n<pre>$ sudo docker run -d --name discourse_app local_discourse\/app\r\n<\/pre>\n<div id=\"attachment_30473\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/09\/Name-Docker-Container.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30473\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/09\/Name-Docker-Container.png\" sizes=\"auto, (max-width: 852px) 100vw, 852px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/09\/Name-Docker-Container.png 852w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/09\/Name-Docker-Container-768x53.png 768w\" alt=\"Name Docker Container\" width=\"852\" height=\"59\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Name Docker Container<\/p>\n<\/div>\n<p>To view a list of all your docker containers, run the following command.<\/p>\n<pre>$ sudo docker ps\r\n<\/pre>\n<div id=\"attachment_30474\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/09\/List-Docker-Containers.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30474\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/09\/List-Docker-Containers.png\" sizes=\"auto, (max-width: 1138px) 100vw, 1138px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/09\/List-Docker-Containers.png 1138w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/09\/List-Docker-Containers-768x42.png 768w\" alt=\"List Docker Containers\" width=\"1138\" height=\"62\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">List Docker Containers<\/p>\n<\/div>\n<p>From now on, every command that worked with a\u00a0<strong>container_id<\/strong>\u00a0can now be used with a name that you assigned, for example.<\/p>\n<pre>$ sudo docker restart discourse_app\r\n$ sudo docker stop discourse_app\r\n$ sudo docker start discourse_app\r\n<\/pre>\n<h3>How to Rename a Docker Container<\/h3>\n<p>To rename a docker container, use the\u00a0<strong>rename sub-command<\/strong>\u00a0as shown, in the following example, we renaming the container\u00a0<strong>discourse_app<\/strong>\u00a0to a new name\u00a0<strong>disc_app<\/strong>.<\/p>\n<pre>$ sudo docker rename discourse_app disc_app\r\n<\/pre>\n<p>After renaming a containers, confirm that it is now using the new name.<\/p>\n<pre>$ sudo docker ps\r\n<\/pre>\n<p>For more information, see the\u00a0<strong>docker-run<\/strong>\u00a0man page.<\/p>\n<pre>$ man docker-run\r\n<\/pre>\n<p>That\u2019s all! In this article, we have expalined how to name and rename Docker containers. Use the comment form below to ask any questions or to add your thoughts to this guide.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/name-docker-containers\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When Docker containers are created, the system automatically assign a universally unique identifier (UUID) number to each container to avoid any naming conflicts and improve automation without human involvement. Read Also:\u00a0How to Install Docker and Learn Basic Container Manipulation in CentOS In this article, we will explain how to easily identify Docker containers and name &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/how-to-name-or-rename-docker-containers\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Name or Rename Docker Containers&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11803","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11803"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11803\/revisions"}],"predecessor-version":[{"id":11804,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11803\/revisions\/11804"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}