使用docker-composer扩展并在主机名后面附加一个数字? [英] Scaling with docker-composer and appending a number to the hostname?
本文介绍了使用docker-composer扩展并在主机名后面附加一个数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 docker-compose.yml
:
master:
build: .
slave:
image: master
hostname: slave
command: run_slave
如何使 docker-compose scale slave = 5
生成具有唯一主机名的计算机?
How can I make docker-compose scale slave=5
generate machines with unique hostnames?
...例如像这样的东西:
...e.g. something like this:
slave1
slave2
slave3
slave4
slave5
推荐答案
无法将主机名设置为该值。
There is no way to set the hostname to that value.
如果您需要一个唯一的标识符,我将使用唯一的容器ID,可以通过运行 $(hostname)$ c来获得$ c>。
If you need a unique identifier, I would use the unique container id, which you can get by running $(hostname)
.
这篇关于使用docker-composer扩展并在主机名后面附加一个数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文