本文介绍了如何在docker-compose中设置主机名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 docker-compose.yml
文件中,具有以下内容。但是,容器不会选择主机名值。
In my docker-compose.yml
file, I have the following. However the container does not pick up the hostname value. Any ideas?
dns:
image: phensley/docker-dns
hostname: affy
domainname: affy.com
volumes:
- /var/run/docker.sock:/docker.sock
当我检查容器中的主机名时,它没有出现 affy
。
When I check the hostname in the container it does not pick up affy
.
推荐答案
自,您只需使用 hostname
键:
As of docker-compose version 3 and later, you can just use the hostname
key:
version: '3'
services:
dns:
hostname: 'your-name'
这篇关于如何在docker-compose中设置主机名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!