DockerCompose常见问题整理
Docker Compose 常见问题整理
容器内部无法通信
将容器处于同一个自定义网络即可
1 | services: |
MySQL 无法执行初始化 sql
需要保证 mysql/data 目录为空
1 | volumes: |
WARNING,需要设置 ‘vm.overcommit_memory = 1’
提示:WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
解决:
1 | wsl --list --verbose |
Redis 指定配置文件启动失败
原因:配置文件设置了 daemonize yes,与 compose up -d 冲突
解决:设置 daemonize no
端口不可用
netstat -ano | findstr 8080,查看端口是否真的没有占用
提示:Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:8080 -> 0.0.0.0:0: listen tcp 0.0.0.0:8080: bind: An attempt was made to access a socket in a way forbidden by its access p ermissions.
解决:
1 | https://medium.com/@sevenall/completely-solve-the-problem-of-docker-containers-not-starting-or-running-on-windows-10-due-to-port-57f16ed6143 |