<service name>:
image: techgeeks/php-apache-dev:latest
hostname: <your-domain.com>
container_name: <your-domain.com>
restart: unless-stopped
networks:
- proxy
environment:
- PUID=${PUID}
- PGID=${PGID}
volumes:
- ${DATADIR}/apache24/<your-domain.com>/www:/var/www/html/
#### ATTENTION
# Leave the following volumes disabled in the first run, you can enable them later if you need them!
####
#- ${DATADIR}/apache24/<your-domain.com>/config/apache:/etc/apache2/
#- ${DATADIR}/apache24/<your-domain.com>/config/php:/usr/local/etc/php/
labels:
- "traefik.enable=true"
# Router HTTP for https redirection
- "traefik.http.routers.<service name>-http.rule=Host(`<your-domain.com>`)"
- "traefik.http.routers.<service name>-http.entrypoints=web"
- "traefik.http.routers.<service name>-http.middlewares=https-redirect@file"
# Router HTTPS
- "traefik.http.routers.<service name>.rule=Host(`<your-domain.com>`)"
- "traefik.http.routers.<service name>.tls=true"
- "traefik.http.routers.<service name>.tls.certresolver=le"
- "traefik.http.routers.<service name>.entrypoints=websecure"
- "traefik.http.services.<service name>.loadbalancer.server.port=80"
Run your docker-compose
Copy default container files to your host
sudo mkdir <DATADIR>/apache24/<your-domain.com>/config
sudo docker cp <container-id><service name>:/etc/apache2/ <DATADIR>/apache24/<your-domain.com>/config/
sudo docker cp <container-id><service name>:/usr/local/etc/php/ <DATADIR>/apache24/<your-domain.com>/config/
sudo mv <DATADIR>/apache24/<your-domain.com>/config/apache2 <DATADIR>/apache24/<your-domain.com>/config/apache
Change permissions to your docker user, this will allow you to change, add or remove files
sudo chown -R <docker-user>:<docker-group> <DATADIR>/apache24
Activate the additional volumes in your docker-compose file
- ${DATADIR}/apache24/<your-domain.com>/config/apache:/etc/apache2/
- ${DATADIR}/apache24/<your-domain.com>/config/php:/usr/local/etc/php/
Run your docker-compose again
Key | Example |
---|---|
<service name> |
example-website |
<your-domain.com> |
example.com |
<docker-user> |
docker |
<docker-group> |
docker |
<DATADIR> |
/srv/docker |