Docker Deploy堆栈额外的主机被忽略 [英] Docker Deploy stack extra hosts ignored
问题描述
docker stack deploy不尊重我撰写文件中的extra_hosts参数。当我执行一个简单的docker-compose up时,该条目会在/ etc / hosts中创建,但是当我执行docker deploy –compose-file docker-compose.yml myapp时,它将忽略extra_hosts,有何见解?
以下是docker-compose.xml:
docker stack deploy isnt respecting the extra_hosts parameter in my compose file. when i do a simple docker-compose up the entry is created in the /etc/hosts however when i do docker deploy –compose-file docker-compose.yml myapp it ignores extra_hosts, any insights? Below is the docker-compose.xml:
version: '3'
services:
web:
image: user-service
deploy:
labels:
- the label
build:
context: ./
environment:
DATABASE_URL: jdbc:postgresql://dbhost:5432/postgres
ports:
- 9002:9002
extra_hosts:
- "dbhost: ${DB_HOST}"
networks:
- wellness_swarm
env_file:
- .env
networks:
wellness_swarm:
external:
name: wellness_swarm
docker-compose配置还可以正确显示撰写文件。
the docker-compose config also displays the compose file properly.
推荐答案
这可能不是对问题的直接答案,因为它不使用env变量,但是我发现在compose文件中的extra_hosts块是如果以上述格式输入,在群模式下将被忽略。
This may not be a direct answer to the question as it doesn't use env variables but what I found was that the extra_hosts block in the compose file was ignored in swarm mode if entered in the format above.
ie这对我有用,并将条目放在容器的/ etc / hosts中:
i.e. this works for me and puts entries in /etc/hosts in the container:
extra_hosts:
retisdev: 10.48.161.44
retistesting: 10.48.161.44
而以其他格式输入时,在以下情况下将被忽略部署为服务
whereas when entered in the other format it gets ignored when deploying as a service
extra_hosts:
- "retisdev=10.48.161.44"
- "retistesting=10.48.161.44"
这篇关于Docker Deploy堆栈额外的主机被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!