2017-11-17 6 views
1

Ich versuche, Dockerfile zu erstellen, um ein Image für eine lokale Entwicklungsumgebung zu erstellen, aber jedes Mal, wenn ich Docker das Image ausführen lassen, wird ein DB-Server (Mariadb/Mysql) beendet mit dem Status 0.Docker CentOS - Mariadb (Exit-Status 0; erwartet)

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)** 

Egal, welche Art von DB-Server (MariaDB/MySQL) ich versuche, die dockerfile hinzuzufügen sein verlassen wird.

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 
+0

Können Sie mir bitte 'supervisord' Konfigurationsdatei zeigen? Denken Sie daran, Sie müssen Datenbank im Vordergrund ausführen –

+0

Danke für die schnelle Antwort, ich habe gerade die supervisord Konfigurationsdatei hinzugefügt. Das Hinzufügen eines -DOREGROUND zum Mariadb-Befehl hat es nicht gelöst. Aber ich kenne Supervisord nicht ... –

Antwort

0

Ich schlage vor, Sie eine gute Strategie zu finden Ihre MariaDB Bild zu debuggen.

Meine Lösung ist eine temporäre CMD in Dockerfile setzen mit

CMD ["sleep", "999999999999999"] 

So können Sie später bash oder sh im gestarteten Container starten und starten Sie MariaDB starten binäre oder Ihre supervisord Befehl.

Allerdings empfehle ich Ihnen ernsthaft, einen Stapel zu bilden, der MariaDB von PHP7 trennt, das Szenario verfolgend, in dem jeder Behälter einen einzelnen Prozess laufen lässt (und ich weiß, PHP saugt dafür). Beginnen Sie mit der Trennung von MariaDB von PHP;)