[英]Running docker-compose with mysql and own docker container
I am trying to start my own container and link it with the official mysql container. 我正在尝试启动自己的容器并将其与官方mysql容器链接。 I am using docker-compose to start both containers and link them together. 我使用docker-compose来启动两个容器并将它们链接在一起。 My own container is supposed to be a regular LAMP-stack which runs a simple PHP application. 我自己的容器应该是一个常规的LAMP堆栈,它运行一个简单的PHP应用程序。
When I run docker-compose up
, they both build properly, but when docker tries to run them, they just stop with the error code mytestservice_web_1 exited with code 0
. 当我运行docker-compose up
,它们都正确构建,但是当docker尝试运行它们时,它们只是停止,错误代码mytestservice_web_1 exited with code 0
。 I can not see any errors in the build log. 我在构建日志中看不到任何错误。
Here is my docker-compose.yml 这是我的docker-compose.yml
web:
build: .
links:
- mysql
ports:
- "80:80"
mysql:
image: mysql:5.6
environment:
- MYSQL_ROOT_PASSWORD=verysecret
Here is my Dockerfile for my own container. 这是我自己的容器的Dockerfile。
FROM linode/lamp
WORKDIR /var/www
RUN a2enmod rewrite
ADD . /var/www/mytestservice
ADD mytestservice.conf /etc/apache2/sites-enabled/
CMD service apache2 start
If I start them manually with docker run there are no problems. 如果我用docker run手动启动它们就没有问题。
How can I keep the containers running? 如何保持容器运行?
正如我在上面的评论中提到的:
CMD exec /usr/sbin/apachectl -D FOREGROUND
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.