Docker compose apache not working

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.

Upvotes: 0

Views: 1969

Answers (1)

dnephin
dnephin

Reputation: 28050

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.

Upvotes: 1

Related Questions