From de42f57b81d042450dee326f9a63b80d9c1521b7 Mon Sep 17 00:00:00 2001
From: Quentin McGaw
- In example, to access port `8000` of container `xyz` and `9000` of container `abc` connected to PIA: - **With recent changes to the firewall**, you might be able to simply publish ports `8000` and `9000` for the PIA container and access them as you would - with any other container. Otherwise... - - 1. Create the file *Caddyfile* - - ```sh - touch Caddyfile - chown 1000 Caddyfile - # chown 1000 because caddy-scratch runs as user ID 1000 by default - chmod 600 Caddyfile - ``` - - with this content: - - ```ruby - :8000 { - proxy / xyz:8000 - } - :9000 { - proxy / abc:9000 - } - ``` - - You can of course make more complicated Caddyfile (such as proxying `/xyz` to xyz:8000 and `/abc` to abc:9000, just ask me!) - - 1. Run Caddy with - - ```sh - docker run -d -p 8000:8000/tcp -p 9000:9000/tcp \ - --link pia:xyz --link pia:abc \ - -v $(pwd)/Caddyfile:/Caddyfile:ro \ - qmcgaw/caddy-scratch - ``` - - **WARNING**: Make sure the Docker network in which Caddy runs is the same as the one of PIA. It can be the default `bridge` network. - - 1. You can now access xyz:8000 at [localhost:8000](http://localhost:8000) and abc:9000 at [localhost:9000](http://localhost:9000) - - For more containers, add more `--link pia:xxx` and modify the *Caddyfile* accordingly - - If you want to user a *docker-compose.yml*, you can use this example - **make sure PIA is launched and connected first**: - - ```yml - version: '3' - services: - piaproxy: - image: qmcgaw/caddy-scratch - container_name: piaproxy - ports: - - 8000:8000/tcp - - 9000:9000/tcp - external_links: - - pia:xyz - - pia:abc - volumes: - - ./Caddyfile:/Caddyfile:ro - abc: - image: abc - container_name: abc - network_mode: "container:pia" - xyz: - image: xyz - container_name: xyz - network_mode: "container:pia" - ``` + In example, to access port `8000` of container `xyz` and `9000` of container `abc` connected to PIA, + publish ports `8000` and `9000` for the PIA container and access them as you would with any other container