Closed NS-Sp4ce closed 2 years ago
已解决,更改docker-compose.yaml为如下
version: "3.9"
services:
mysql:
image: mysql/mysql-server:5.7
container_name: code6-mysql
restart: always
env_file:
- .env.docker-compose
networks:
- code6-network
ports:
- ${MYSQL_PORT}:3306
volumes:
- /etc/localtime:/etc/localtime:ro
- ${MYSQL_VOLUME_PATH}:/var/lib/mysql
healthcheck:
test: mysql ${MYSQL_DATABASE} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -e 'SELECT 1'
interval: 5s
retries: 10
start_period: 60s
code6:
image: code6
build:
context: .
dockerfile: Dockerfile
container_name: code6-server
depends_on:
mysql:
condition: service_healthy
restart: always
env_file:
- .env.docker-compose
environment:
MYSQL_HOST: mysql
MYSQL_PORT: 3306
MYSQL_USERNAME: ${MYSQL_USER}
ports:
- ${PORT}:80
networks:
- code6-network
links:
- mysql
networks:
code6-network:
name: code6-network
.env.docker-compose为如下
# Web 映射到宿主机的端口
PORT=666
# MySQL 映射到宿主机的端口
MYSQL_PORT=3306
# MySQL 数据库名
MYSQL_DATABASE=code6
# MySQL 用户名
MYSQL_USER=root
# MySQL 密码
MYSQL_PASSWORD=root
MYSQL_ROOT_PASSWORD=root
# MySQL 挂载到宿主机的目录
MYSQL_VOLUME_PATH=/data
``
启动成功
1.环境
2.报错时的配置
.env.docker-compose
3.报错时的启动log(不带--verbose)
docker ps
4.报错时的启动log(带--verbose,清空container、images安装)
带
--verbose
启动时会打印出启动失败前的日志,观察到存在大量的如下日志4.已尝试如下配置