gpt4 book ai didi

mysql - Docker CentOS - mariadb(退出状态 0;预期)

转载 作者:行者123 更新时间:2023-11-30 21:50:50 24 4
gpt4 key购买 nike

我正在尝试创建 dockerfile 来为本地开发环境构建图像,但每次我让 docker 运行图像时,数据库服务器 (mariadb/mysql) 都会以状态 0 退出。

2017-11-17 08:36:10,854 CRIT Supervisor running as root (no user in config file)
2017-11-17 08:36:10,864 INFO RPC interface 'supervisor' initialized
2017-11-17 08:36:10,865 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2017-11-17 08:36:10,865 INFO supervisord started with pid 1
2017-11-17 08:36:11,873 INFO spawned: 'httpd' with pid 9
2017-11-17 08:36:11,876 INFO spawned: 'mariadb' with pid 10
2017-11-17 08:36:12,973 INFO success: httpd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2017-11-17 08:36:12,974 INFO success: mariadb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
**2017-11-17 08:36:13,327 INFO exited: mariadb (exit status 0; expected)**

无论我尝试将什么类型的数据库服务器(MariaDB/MySQL)添加到 dockerfile,它都会退出。

Dockerfile

FROM centos:centos7
# Install tools
RUN yum -y install curl wget unzip git vim python-setuptools yum-utils which epel-release

# Install Python and Supervisor
RUN yum -y install python-setuptools \ && mkdir -p /var/log/supervisor \ && easy_install supervisor

# Install Apache
RUN yum -y install httpd

# Install Remi Updated PHP 7
RUN wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm \ && rpm -Uvh remi-release-7.rpm \ && yum-config-manager --enable remi-php70 \ && yum -y install php php-devel php-gd php-pdo php-soap php-xmlrpc php-xml

# Reconfigure Apache
RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf \ && chown root:apache /var/www/html \ && chmod g+s /var/www/html

# Install MariaDB
RUN yum -y install mariadb-server

COPY supervisord.conf /etc/supervisord.conf
EXPOSE 80 3306
CMD ["/usr/bin/supervisord"]

supervisord.conf

[unix_http_server]

file=/tmp/supervisor.sock

[supervisord] nodaemon=true

[program:mariadb] command=/usr/bin/mysqld_safe

[program:httpd] command=/usr/sbin/httpd -DFOREGROUND

[group:allservices] programs=mariadb,httpd

[rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl] serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket

最佳答案

我建议您找到一个好的策略来调试您的 MariaDB 镜像。

我的解决方案是在 Dockerfile 中设置一个临时 CMD

CMD ["sleep", "999999999999999"]

因此,您稍后可以在启动的容器中启动 bash 或 sh,然后启动 MariaDB 启动二进制文件或您的 supervisord 命令。

但是,我强烈建议您构建一个将 MariaDB 与 PHP7 分开的堆栈,以实现每个容器运行单个进程的场景(我知道,PHP 在这方面很糟糕)。首先将 MariaDB 与 PHP 分开 ;)

关于mysql - Docker CentOS - mariadb(退出状态 0;预期),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47348571/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com