Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running docker-compose with mysql and own docker container

Tags:

docker

mysql

I am trying to start my own container and link it with the official mysql container. I am using docker-compose to start both containers and link them together. My own container is supposed to be a regular LAMP-stack which runs a simple PHP application.

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. I can not see any errors in the build log.

Here is my 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.

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.

How can I keep the containers running?

like image 492
magnudae Avatar asked Mar 05 '15 08:03

magnudae


1 Answers

As mentioned in my comment above:

CMD exec /usr/sbin/apachectl -D FOREGROUND
like image 165
Abdullah Jibaly Avatar answered Oct 21 '22 01:10

Abdullah Jibaly