我有一个docker-compose项目,想要在没有启用IPv6的服务器上运行。每当我尝试运行容器时,就会出现以下错误消息:nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
我认为这是因为我的服务器未启用IPv6(由第三方管理,无法更改设置),因此我尝试禁用docker-compose的IPv6,但到目前为止仍然没有成功。
我尝试添加
sysctls:
net.ipv6.conf.all.disable_ipv6: 1
我在我的配置文件中设置了IPv6,但是收到以下错误信息
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: open /proc/sys/net/ipv6/conf/all/disable_ipv6: no such file or directory: unknown
我应该如何在docker-compose中禁用IPv6,以避免像这样的问题,无论是针对此特定容器还是系统范围内?
这是我当前的配置
container_name: cont-nginx
networks:
- cont
image: nginx:latest
depends_on:
- cont-app
restart: always
ports:
- "880:880"
- "4443:4443"
sysctls:
- net.ipv6.conf.all.disable_ipv6=1
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
networks:
cont:
driver: bridge