docker-compose up -d 运行容器秒自动停止解决方案
正常的我们运行Docker-Compose的服务
docker-compose -f docker-compose.yml up -d mysql-setup
执行Docker ps 查看存活的容器
Docker PS发现没失败但是未找到存活的容器
查看日志
docker logs mysql-setup
发现并没有报错。。。。
检查DockerFile
# Default override to use MySQL as a backing store for datahub-gms (same as docker-compose.mysql.yml).
---
version: '3.9'
services:
mysql-setup:
container_name: mysql-setup
hostname: mysql-setup
image: ${DATAHUB_MYSQL_SETUP_IMAGE:-acryldata/datahub-mysql-setup}:${DATAHUB_VERSION:-head}
build:
context: ../
dockerfile: docker/mysql-setup/Dockerfile
env_file: mysql-setup/env/docker.env
depends_on:
mysql:
condition: service_healthy
labels:
datahub_setup_job: true
mysql:
container_name: mysql
hostname: mysql
image: mysql:${DATAHUB_MYSQL_VERSION:-5.7}
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --default-authentication-plugin=mysql_native_password
ports:
- ${DATAHUB_MAPPED_MYSQL_PORT:-3306}:3306
env_file: mysql/env/docker.env
restart: on-failure
healthcheck:
test: mysqladmin ping -h mysql -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
start_period: 10s
interval: 1s
retries: 3
timeout: 5s
volumes:
- ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
- mysqldata:/var/lib/mysql
volumes:
mysqldata:
解决方案
还需要挂在三个命令即可: command: /bin/bash tty: true stdin_open: true
mysql-setup:
container_name: mysql-setup
hostname: mysql-setup
image: ${DATAHUB_MYSQL_SETUP_IMAGE:-acryldata/datahub-mysql-setup}:${DATAHUB_VERSION:-head}
command: /bin/bash
build:
context: ../
dockerfile: docker/mysql-setup/Dockerfile
env_file: ./mysql-setup/env/docker.env
depends_on:
mysql:
condition: service_healthy
labels:
datahub_setup_job: true
tty: true
stdin_open: true
再次启动成功
作者:隔壁老郭
个性签名:独学而无友,则孤陋而寡闻。做一个灵魂有趣的人!
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!
Java入门到入坟
万水千山总是情,打赏一分行不行,所以如果你心情还比较高兴,也是可以扫码打赏博主,哈哈哈(っ•̀ω•́)っ✎⁾⁾!