-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Docker Compose Example
Nicolas Duchon edited this page Dec 8, 2024
·
3 revisions
Create docker network, which is going to be used by proxy and proxied servers.
docker network create proxy-net
Example of docker-compose.yaml
services:
proxy:
container_name: proxy
image: nginxproxy/nginx-proxy
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
environment:
- TRUST_DOWNSTREAM_PROXY=false # true if there is another proxy in front of this one
networks:
- proxy-net # proxy and all proxied servers have to be on the same network
proxied_server1:
image: your_image:latest
environment:
- VIRTUAL_HOST=your.domain.com
- VIRTUAL_PORT=3000 # the same port as in expose
expose:
- 3000 # port your app uses to communicate
depends_on:
- proxy
networks:
- proxy-net
networks:
proxy-net:
name: proxy-net
external: true