对于network_mode:主机服务,
version: '2'
services:
redis:
image: 'docker.io/bitnami/redis:6.0-debian-10'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
ports:
- "6379:6379"
volumes:
- 'redis_data:/bitnami/redis/data'
demo:
image: demo
container_name: "demo"
network_mode: host
command: bash -c "cd /sample/ ; python manage.py makemigrations --noinput ; python manage.py migrate --run-syncdb; python manage.py runserver 0.0.0.0:demo --noreload"
privileged: true
ports:
- "8080:80"
depends_on:
- redis
我正在将redis图像用于Django通道功能,但是当我做docker-compose时,我得到的错误低于
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
如果我从docker-compose中删除network_mode: host
,则不会出现任何错误,并且可以成功地使容器启动并运行
我必须在docker-compose中添加network_mode: host
以获得项目特定的依赖关系,我如何才能成功地使Redis服务器启动并以network_mode: host
运行,任何帮助将不胜感激