Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to rename a container in docker

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to rename a container in docker". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to rename a container in docker.

When you create a docker container, it is assigned a globally unique identifier (UUID). This is essential to avoid naming conflicts and to move away from human intervention to promote automation.

Docker also supports containers with a randomly generated name of 2 words, highlighted with a bottom line, such as evil_ptolemy. This makes it easier to tell a person which container it is. But random names don't give people more insight into the operation of the container than UUID does.

Naming when you run the container

By adding-name=meaningful_name to let docker run commands, an evil_ptolomy becomes more recognizable in the interaction process and like docker ps output commands. However, this has its limitations. After the automatic container name must be unique, you cannot use a questionable name and the size of the service exceeds one container.

On the command line or in a file:

Docker run-name=meaningful_name

For example: if we run a container based on the Nginx base image and start like this:

Docker run-- name nginx-d nginx

The name is displayed in the list of running containers:

Docker psOutputCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES08f333ef7216 nginx "nginx-g'daemon off" 15 seconds ago Up 14 seconds 80/tcp, 443/tcp nginx

When the docker ps name appears in the output and can be used to manage the container, it will not appear in the container's command prompt if you link it or in the log file.

Rename docker Container

Please use the name subcommand, docker rename the original container name and the new container name. In the following example, we renamed the container discourse_app to the new name disc_app.

$sudo docker rename discourse_app disc_app

After renaming the container, verify that it now uses the new name.

$sudo docker ps

For more information, see the docker-run man page.

$man docker-run

Thank you for reading, the above is the content of "how to rename containers in docker". After the study of this article, I believe you have a deeper understanding of how to rename containers in docker, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report