You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+36-2Lines changed: 36 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ Legacy link refers to the link created before docker 1.10, and the link created
76
76
**Note**: Any link alias sharing the same prefix and followed by "-/_" with an integer is considered to be from the same service. For example: `web-1` and `web-2` belong to service `web`, `app_1` and `app_2` are from service `app`, but `app1` and `web2` are from different services.
77
77
78
78
79
-
### Running with Docker Compose v2(new links, compatible with Docker Swarm)
79
+
### Running with Docker Compose v2(new links)
80
80
81
81
Docker Compose 1.6 supports a new format of the compose file. In the new version(v2), the old link that injects environment variables is deprecated.
82
82
@@ -86,7 +86,6 @@ Similar to using legacy links, here list some differences that you need to notic
86
86
- A link is required in order to ensure that dockercloud/haproxy is aware of which service it needs to balance, although links are not needed for service discovery since docker 1.10. Linked aliases are not required.
87
87
- DO not overwrite `HOSTNAME` environment variable in `dockercloud/haproxy container`.
88
88
- As it is the case on Docker Cloud, auto reconfiguration is supported when the linked services scales or/and the linked container starts/stops.
89
-
- This image is also compatible with Docker Swarm, and supports the docker native `overlay` network across multi-hosts.
90
89
91
90
##### example of docker-compose.yml running in linux:
92
91
@@ -124,6 +123,41 @@ Similar to using legacy links, here list some differences that you need to notic
124
123
125
124
Once the stack is up, you can scale the web service using `docker-compose scale web=3`. dockercloud/haproxy will automatically reload its configuration.
126
125
126
+
#### Running with Docker Compose v2 and Swarm (using envvar)
127
+
When using links like previous section, the Docker Swarm scheduler can be too restrictive.
128
+
Even with overlay network, swarm (As of 1.1.0) will attempt to schedule haproxy on the same node as the linked service due to legacy links behavior.
129
+
This can cause unwanted scheduling patterns or errors such as "Unable to find a node fulfilling all dependencies..."
130
+
131
+
Since Compose V2 allows discovery through the service names, Dockercloud haproxy only needs the links to indentify which service should be load balanced.
132
+
133
+
A second option is to use the `ADDITIONAL_SERVICES` variable for indentification of services.
134
+
135
+
- Set the `ADDITIONAL_SERVICES` env variable to your linked services.
136
+
- You also want to set depends_on to ensure the web service is started before haproxy so that the hostname can be resolved. This controls scheduling order but not location.
137
+
- The container still needs access to the docker daemon to get load balanced containers' configs.
138
+
- If any trouble with haproxy not updating the config, try running reload.sh or set the `DEBUG` envvar.
139
+
- This image is also compatible with Docker Swarm, and supports the docker native `overlay` network across multi-hosts.
140
+
141
+
##### example of docker-compose.yml in 'project_dir' directory running in linux:
0 commit comments