Reputation: 2443
I'm new to Docker. I'm trying to change Document Root for my app. my-app directory has my php codes.
Tree
Project
- docker-compose.yml
- html
- my-app
- php
- 000-default.conf
- Dockerfile
docker-compose.yml
version: "3"
services:
php:
build: ./php/
# image: php:7.2-apache
volumes:
- ./html:/var/www/html
ports:
- 8080:80
container_name: php7.2
restart: always
Dockerfile
FROM php:7.2-apache
RUN apt-get -y update && apt-get -y install vim
COPY 000-default.conf /etc/apache2/sites-available/
000-default.conf
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/my-app
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
EnableSendfile off
</VirtualHost>
I command docker-compose up -d --build
, however document root never change to my-app where I expect. I confirmed 000-default.conf
has changed by COPY inside of container.
Please give me same advice. Thanks.
Upvotes: 2
Views: 3958
Reputation: 164879
You appear to have your ports back-to-front. In your docker-compose.yml
file, you've set host port 8080 and container port 80 (👍) but your v-host is listening on container port 8080.
I'm not actually seeing any reason for you to override the default site config nor for you to have a Dockerfile
at all. The default site serves content from /var/www/html
over container port 80 so you don't need to change that.
Try this config instead
version: "3"
services:
php:
image: php:7.2-apache
volumes:
- "./html:/var/www/html"
ports:
- "8080:80"
Run the stack using
docker-compose up -d
then open http://localhost:8080/my-app/
in your browser.
Upvotes: 1