为什么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,我正在使用:
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
谢谢。
推荐答案
编辑。
此更改在v1.23.2中恢复
This change is reverted in v1.23.2
因此,撰写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
已创建容器的默认命名方案在此
版本ha中撰写s从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屋!