为什么docker容器名称末尾有一个随机数? [英] Why docker container name has an random number at the end?
问题描述
我有一个 docker-compose.yml 文件如下(其中的一部分):
I have a docker-compose.yml file as below (a piece of it):
version: '3.5'
services:
framework:
image: ${DOCKER_REGISTRY}/gme/fmk:${COMPOSE_PROJECT_NAME}
build: ./fmk
ports:
- "2020:2020"
- "2025:2025"
- "4999:4999"
volumes:
- ${FOLDER_ENV}/workspace/logs/framework:/var/log/gcti
- ${FOLDER_ENV}/..:/usr/local/genesys/gsg_qaart
我得到的是:
vagrant@docker:/repos/gsg_qaart/docker$ docker-compose ps
] Name Command State
Ports
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
callback_framework_1_df361f67842c /bootstrap.sh Up 0.0.0.0:2020->2020/tcp, 0.0.0.0:2025->2025/tcp, 0.0.0.0:4999->4999/tcp, 5432/tcp
正如你看到的名字很奇怪,它应该是callback_framwork_1",为什么最后有一个随机数?
As you can see the name is weird, it supposes to be "callback_framwork_1", why there is a random number at the end?
顺便说一句,我正在使用:
BTW, I'm using:
vagrant@docker:/repos/gsg_qaart/docker$ docker -v
Docker version 18.09.0, build 4d60db4
vagrant@docker:/repos/gsg_qaart/docker$ docker-compose -v
docker-compose version 1.23.1, build b02f1306
谢谢.
推荐答案
EDIT.
此更改在 v1.23.2 中恢复
This change is reverted in v1.23.2
所以compose v1.23有一个重要的变化,https://github.com/docker/compose/releases/tag/1.23.0
So there is an important change in the compose v1.23, https://github.com/docker/compose/releases/tag/1.23.0
Compose 在此创建的容器的默认命名方案版本已从 project_service_index 更改为project_service_index_slug,其中 slug 是随机生成的十六进制字符串.请务必更新脚本在升级之前相应地依赖于旧的命名方案.
The default naming scheme for containers created by Compose in this version has changed from project_service_index to project_service_index_slug, where slug is a randomly-generated hexadecimal string. Please make sure to update scripts relying on the old naming scheme accordingly before upgrading.
因此,如果您想要一个确定性的容器名称,请使用
Therefore if you want to have a deterministic container name, use
services:
framework:
container_name: framework
这篇关于为什么docker容器名称末尾有一个随机数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!