0

I'm trying to run a container using docker compose. I already did it using normal docker commands and it works, but when I do the same using docker compose it did not work as expected.

I compile the image using docker compose build command:

docker-compose build php

and use that image for both docker and docker-compose commands.

docker run -p 80:80 -v /navicu docker_php
docker-compose up php

I allays change the port of one of the container so they never collapse. For example: port 80 on docker and 800 on docker-compose.

The problem is that no matter what I do, the docker-compose container is not working as expected. It doesn't let connections on the localhost (it shows a 500 error). On the other hand the docker container allows the connection and show the page as expected.

Here is the docker-compose.yml:

php:
  build: .
  ports:
   - "80:80"
  volumes:
   - ./navicu:/navicu

PD: the Dockerfile use a php-apache official image and add a vhost.conf file.

2
  • Just to clarify: you're trying to connect to the host (the one running the docker images) or to the docker image itself? Commented Nov 25, 2015 at 22:49
  • I tried both host. It is the same since I bind the port of the host to the port of the container. For example if I curl localhost on the host and on the container (the one that come from docker run) it works but when I do the same on the other container (the one that come from docker-compose) it doesn't work. Commented Nov 26, 2015 at 1:11

1 Answer 1

1

The docker run is not equivalent to the compose file. If you try

docker run -p 80:80 -v $PWD/navicu:/navicu docker_php

it would be the same, and I expect you'll see the same 500 error.

The equivalent compose volumes would be

volumes:
    - /navicu

I believe the reason you're getting a 500 error is because you're replacing the container contents at /navicu with the files in the host directory, which are probably not correct, or are missing things.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.