1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2024-11-25 13:26:30 +00:00

Merge pull request #493 from ryneeverett/docker_compose_separate_containers

Add docker-compose file for separate containers.
This commit is contained in:
Jason Wilder 2016-09-09 14:18:06 -06:00 committed by GitHub
commit 40d433ae80
2 changed files with 32 additions and 1 deletions

View File

@ -42,7 +42,7 @@ services:
```shell
$ docker-compose up
$ curl -H "Host: whoami.local" localhost
I''m 5b129ab83266
I'm 5b129ab83266
```
### Multiple Ports
@ -98,6 +98,14 @@ image and the official [nginx](https://registry.hub.docker.com/_/nginx/) image.
You may want to do this to prevent having the docker socket bound to a publicly exposed container service.
You can demo this pattern with docker-compose:
```console
$ docker-compose --file docker-compose-separate-containers.yml up
$ curl -H "Host: whoami.local" localhost
I'm 5b129ab83266
```
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.
First start nginx with a volume:

View File

@ -0,0 +1,23 @@
version: '2'
services:
nginx:
image: nginx
container_name: nginx
ports:
- "80:80"
volumes:
- /etc/nginx/conf.d
dockergen:
image: jwilder/docker-gen
command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
volumes_from:
- nginx
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
whoami:
image: jwilder/whoami
environment:
- VIRTUAL_HOST=whoami.local