8

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?

4
  • My guess is the : in mysql:5.6 is throwing off the yaml syntax. Try wrapping it in quotes: image: "mysql:5.6" Commented Mar 5, 2015 at 14:55
  • That didn't work. I think the problem is that I do not specify that the containers shall keep on running. I am running a lamp image which does not have a clear way to keep running, unless I start it with bash. Commented Mar 6, 2015 at 7:32
  • Yeah your CMD is wrong, it should start apache as a foreground process. Commented Mar 6, 2015 at 8:41
  • 1
    For example: exec /usr/sbin/apachectl -D FOREGROUND Commented Mar 6, 2015 at 8:46

1 Answer 1

6

As mentioned in my comment above:

CMD exec /usr/sbin/apachectl -D FOREGROUND
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.