简体   繁体   English

运行docker-compose与mysql和自己的docker容器

[英]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. 我自己的容器应该是一个常规的L​​AMP堆栈,它运行一个简单的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.

相关问题 将NodeJS Docker容器连接到MySQL Docker容器-docker-compose 3 - Connecting NodeJS Docker container to a MySQL Docker container - docker-compose 3 使用docker-compose,数据库容器无法启动并运行 - With docker-compose, database container is not up and running Docker-compose 容器连接到 MySql 不起作用 - Docker-compose container connection to MySql not working mySQL init 脚本未与 docker-compose 一起运行 - mySQL init scripts not running with docker-compose docker-compose:MySQL服务没有运行 - docker-compose: MySQL service not running 连接到 docker-compose mysql 容器拒绝访问,但运行相同图像的 docker 不会 - connecting to a docker-compose mysql container denies access but docker running same image does not MySql docker 容器,通过终端工作,通过 docker-compose no - MySql docker container, via terminal works, via docker-compose no 在没有docker-compose的情况下访问Docker(MySQL)容器? - Accessing Docker (MySQL) container without docker-compose? 如何将一个容器中的mysql数据库绑定到运行django博客应用程序的另一个容器(使用docker-compose) - How to tie mysql database in one container to another container running my django blog app (with docker-compose) Docker 无法连接到运行 docker-compose up 的 MySQL - Docker can't connect to MySQL running docker-compose up
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM