对于网络模式:主机服务,
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组成了我得到下面的错误
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
如果我移除 network_mode: host
从docker compose,我没有得到任何错误,我可以成功地使容器和运行
我得补充一句 network_mode: host
在docker compose for project specific dependency中,如何成功地使redis服务器启动并运行 network_mode: host
,任何帮助都将不胜感激
暂无答案!
目前还没有任何答案,快来回答吧!