|
1 | | -## Introduction |
2 | | - |
3 | | -This docker stack will run many services (Traefik (with auth), Socat, Portainer, Nginx, Caddy, Whoami) in a straightforward copy-paste command. Please also refer the [README](https://github.com/pascalandy/docker-stack-this/blob/master/README.md) at the root of this repo. |
4 | | - |
5 | | -## Start here |
6 | | -1. Go to http://labs.play-with-docker.com/ |
7 | | -2. Create **one** instance |
8 | | -3. Copy-paste: |
9 | | - |
10 | | -#### Stable setup (recommended) |
11 | | - |
12 | | -``` |
13 | | -ENV_BRANCH="master" |
14 | | -ENV_MONOREPO="traefik_stack5" |
15 | | -
|
16 | | -# On play-with-docker, install common apps |
17 | | -apk update && apk upgrade && apk add --no-cache \ |
18 | | - nano bash git curl wget unzip openssl tar ca-certificates && \ |
19 | | -rm -rf /var/cache/apk/* /tmp* && \ |
20 | | -docker swarm init --advertise-addr $(hostname -i) && \ |
21 | | -git clone https://github.com/pascalandy/docker-stack-this.git && \ |
22 | | -cd docker-stack-this && \ |
23 | | -git checkout ${ENV_BRANCH} && \ |
24 | | -cd ${ENV_MONOREPO} && \ |
25 | | -./runup.sh; |
26 | | -``` |
27 | | - |
28 | | -#### Edge setup (NOT recommended) |
29 | | - |
30 | | -``` |
31 | | -ENV_BRANCH="edge" |
32 | | -ENV_MONOREPO="traefik_stack5" |
33 | | -
|
34 | | -# On play-with-docker, install common apps |
35 | | -apk update && apk upgrade && apk add --no-cache \ |
36 | | - nano bash git curl wget unzip openssl tar ca-certificates && \ |
37 | | -rm -rf /var/cache/apk/* /tmp* && \ |
38 | | -docker swarm init --advertise-addr $(hostname -i) && \ |
39 | | -git clone https://github.com/pascalandy/docker-stack-this.git && \ |
40 | | -cd docker-stack-this && \ |
41 | | -git checkout ${ENV_BRANCH} && \ |
42 | | -cd ${ENV_MONOREPO} && \ |
43 | | -./runup.sh; |
44 | | -``` |
45 | | - |
46 | | -These scripts will do the hard of deploying the stacks for us. |
47 | | - |
48 | | -#### example |
49 | | - |
50 | | - |
51 | | - |
52 | | -## See your stacks |
53 | | - |
54 | | -``` |
55 | | -$ docker stack ls |
56 | | -
|
57 | | -NAME SERVICES ORCHESTRATOR |
58 | | -toolgui 2 Swarm |
59 | | -toolproxy 2 Swarm |
60 | | -toolwebapp 4 Swarm |
61 | | -``` |
62 | | - |
63 | | - |
64 | | -## See your services |
65 | | - |
66 | | -``` |
67 | | -$ docker service ls |
68 | | -
|
69 | | -ID NAME MODE REPLICAS IMAGE PORTS |
70 | | -xjdsq3gxd59y toolgui_agent global 1/1 portainer/agent:latest |
71 | | -0h375hmmnelo toolgui_portainer replicated 1/1 portainer/portainer:latest |
72 | | -xim07ahqctsp toolproxy_socat replicated 1/1 devmtl/socatproxy:1.2 |
73 | | -y249kaecel8e toolproxy_traefik replicated 1/1 traefik:1.7.12 *:80->80/tcp, *:443->443/tcp, *:8080->8080/tcp |
74 | | -s0061fdhvv6o toolwebapp_home replicated 1/1 abiosoft/caddy:1.0.1-no-stats |
75 | | -ocpk5l6yg2gt toolwebapp_who1 replicated 1/1 nginx:1.15-alpine |
76 | | -raq5czrlhrmb toolwebapp_who2 replicated 1/1 emilevauge/whoami:latest |
77 | | -66b1rduru5k9 toolwebapp_who3 replicated 1/1 emilevauge/whoami:latest |
78 | | -``` |
79 | | - |
80 | | -## Confirm that your services (containers) are running |
81 | | - |
82 | | -1. When you see that all services are deployed, click on `80` to see the static landing page. |
83 | | -2. From the same URL generated by play-with-docker, in the address bar of your browser, add `/who1` or `/who2` or `/who3` or `/portainer` to access other services. |
84 | | - |
85 | | - |
86 | | -#### Full URL example |
87 | | - |
88 | | -``` |
89 | | -http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/ |
90 | | -http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who1 |
91 | | -http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who2 |
92 | | -http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who3 |
93 | | -http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/portainer |
94 | | -``` |
95 | | - |
96 | | -The container for the first URL is named `home`. |
97 | | - |
98 | | - |
99 | | -#### Web apps details: |
100 | | -- **/** = [caddy](https://github.com/pascalandy/caddy-securityheader) |
101 | | -- **/who1** = [caddy](https://github.com/pascalandy/caddy-securityheader) |
102 | | -- **/who2** = [whoami](https://hub.docker.com/r/emilevauge/whoami/) |
103 | | -- **/portainer** = [portainer](https://hub.docker.com/r/portainer/portainer/) |
104 | | - |
105 | | -For /who1 and /who2 you will see the container's Ids (5fe91baf7a3a & 78a0c7287df1) in this example |
106 | | - |
107 | | -``` |
108 | | -$ docker ps | grep whoami |
109 | | -5fe91baf7a3a emilevauge/whoami:latest "/whoamI" About a minute ago Up About a minute 80/tcp toolwebapp_who3.1.9zk09prm85gnl0ieuuncynhxh |
110 | | -78a0c7287df1 emilevauge/whoami:latest "/whoamI" About a minute ago Up About a minute 80/tcp toolwebapp_who2.1.wj7vf83ag91ft7jgdy3gwejp4 |
111 | | -``` |
112 | | - |
113 | | - |
114 | | -## How to access Traefik |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | -#### Traefik password |
120 | | - |
121 | | -**user**: admin / **pass**: changethispass |
122 | | - |
123 | | -This password is encrypted in our configs `.configs/traefik.toml` |
124 | | - |
125 | | -To quickly generate yours with htpasswd, use my container: |
126 | | - |
127 | | -``` |
128 | | -docker run --rm -it devmtl/alpinefire:3.8-D sh -c 'htpasswd -Bbn admin changethispass' |
129 | | -``` |
130 | | - |
131 | | -This will display: |
132 | | - |
133 | | -``` |
134 | | -admin:$2y$05$pAfipn3.brdHMI2eWGnYH.84XYqLozp1sUPi36/l54UAwv.zGLtNC |
135 | | -``` |
136 | | - |
137 | | -Insert this string in your `.configs/traefik.toml`. |
138 | | - |
139 | | -#### What is Traefik? |
140 | | - |
141 | | -[Traefik](https://docs.traefik.io/configuration/backends/docker/) is a powerful layer 7 reverse proxy. Once running, the proxy will give you access to many web apps. I think this is a substantial use case to understand how this reverse-proxy works. |
142 | | - |
143 | | -#### Traefik version |
144 | | - |
145 | | -In `toolproxy.yml` look for something like `traefik:1.7.12`. |
146 | | - |
147 | | -In some mono-repo, I **my own traefik image**. Feel free to use the official images. It will not break anything. |
148 | | - |
149 | | -#### Other stuff to know? |
150 | | - |
151 | | -- This stack does not use ACME (https://). ACME is a pain while developing … reaching limits, etc. |
152 | | -- If you don’t want to use socat, check out the monorepo `traefik-manager-noacme` |
153 | | - |
154 | | -## Screenshots |
155 | | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | -## All commands |
166 | | -In the active path, just execute those bash-scripts: |
167 | | - |
168 | | -- `./runup.sh` |
169 | | -- `./rundown.sh` |
170 | | -- `./runctop.sh` |
171 | | - |
172 | | -**Bonus!** `./runctop.sh` is not a stack but a simple docker run to see the memory consumed by each container. |
173 | | - |
| 1 | +wip |
0 commit comments