Skip to content

Commit 5f684d4

Browse files
committed
Add docker-compose file for separate containers.
Demonstrate that this pattern works. This is based on the example at <https://github.com/fatk/docker-letsencrypt-nginx-proxy-companion-examples/blob/master/docker-compose/v2/simple-site/docker-compose.yml>.
1 parent a2ab836 commit 5f684d4

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ services:
4242
```shell
4343
$ docker-compose up
4444
$ curl -H "Host: whoami.local" localhost
45-
I''m 5b129ab83266
45+
I'm 5b129ab83266
4646
```
4747

4848
### Multiple Ports
@@ -92,6 +92,14 @@ image and the official [nginx](https://registry.hub.docker.com/_/nginx/) image.
9292

9393
You may want to do this to prevent having the docker socket bound to a publicly exposed container service.
9494

95+
You can demo this pattern with docker-compose:
96+
97+
```console
98+
$ docker-compose --file docker-compose-separate-containers.yml up
99+
$ curl -H "Host: whoami.local" localhost
100+
I'm 5b129ab83266
101+
```
102+
95103
To run nginx proxy as a separate container you'll need to have [nginx.tmpl](https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl) on your host system.
96104

97105
First start nginx with a volume:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '2'
2+
services:
3+
nginx:
4+
image: nginx
5+
container_name: nginx
6+
ports:
7+
- "80:80"
8+
volumes:
9+
- /etc/nginx/conf.d
10+
networks:
11+
- proxy-tier
12+
13+
dockergen:
14+
image: jwilder/docker-gen
15+
command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
16+
volumes_from:
17+
- nginx
18+
volumes:
19+
- /var/run/docker.sock:/tmp/docker.sock:ro
20+
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
21+
networks:
22+
- proxy-tier
23+
24+
whoami:
25+
image: jwilder/whoami
26+
environment:
27+
- VIRTUAL_HOST=whoami.local
28+
networks:
29+
- proxy-tier
30+
31+
networks:
32+
proxy-tier:
33+
driver: bridge

0 commit comments

Comments
 (0)