From 5f684d4fc5b5466f351492e94fc0c4279c9b6750 Mon Sep 17 00:00:00 2001 From: ryneeverett Date: Mon, 27 Jun 2016 01:26:39 -0400 Subject: [PATCH] Add docker-compose file for separate containers. Demonstrate that this pattern works. This is based on the example at . --- README.md | 10 +++++++- docker-compose-separate-containers.yml | 33 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 docker-compose-separate-containers.yml diff --git a/README.md b/README.md index b12c9c2..0a9fe79 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ services: ```shell $ docker-compose up $ curl -H "Host: whoami.local" localhost -I''m 5b129ab83266 +I'm 5b129ab83266 ``` ### Multiple Ports @@ -92,6 +92,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: diff --git a/docker-compose-separate-containers.yml b/docker-compose-separate-containers.yml new file mode 100644 index 0000000..dc41c01 --- /dev/null +++ b/docker-compose-separate-containers.yml @@ -0,0 +1,33 @@ +version: '2' +services: + nginx: + image: nginx + container_name: nginx + ports: + - "80:80" + volumes: + - /etc/nginx/conf.d + networks: + - proxy-tier + + 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 + networks: + - proxy-tier + + whoami: + image: jwilder/whoami + environment: + - VIRTUAL_HOST=whoami.local + networks: + - proxy-tier + +networks: + proxy-tier: + driver: bridge