- Notifications
You must be signed in to change notification settings - Fork1
Serve multiple docker container with the help of haproxy.
License
factorial-io/multibasebox
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Serve multiple docker container with the help of haproxy. Requires a running docker-environment
Multibasebox consists of a simple shell script setting up name resolution and a haproxy container on your local environment.
For serving the different containers a separate docker-container namedhaproxy-config will be pulled and started.
haproxy is listening on port 80 and 443 and will forward all requests to a specific docker-image. It uses the hostname to distinguish the containers.
Phabalicious is nicely integrated with multibasebox and has a dedicated command to setup multibasebox since version 3.3. Run
phab workspace:create
and answer the questions. The scaffolder will create afabfile.local.yaml
suited to your local setup.
That's it!
- Clone this repository,
- Run
bash ./setup-docker.sh
- Visit
http://multibasebox.test:1936
This will show you the haproxy status page.
If you installed multibasebox with phabalicious, the following part is just for your information, as the phabalicious created this file already. Here's a short example forfabfile.local.yaml
, adapt it to your setup and it should work:
dockerHosts:mbb:runLocally:truerootFolder:<absolute-path-to-projects-folder>hosts:mbb:xdebug:remote_host:docker.for.mac.localhostblueprint:xdebug:remote_host:docker.for.mac.localhost
The script won't run the dnsmasq-container for linux, but there are some workarounds:
Create
/etc/NetworkManager/conf.d/00-use-dnsmaq.conf
with the following contentdns=dnsmasq
Create
/etc/NetworkManager/dnsmasq.d/test.conf
withlocal=/test/address=/.test/127.0.0.1addn-hosts=/etc/hosts
Restart the NetworkManager with
sudo systemctl restart NetworkManager
Add your hosts to/etc/hosts
similar to
127.0.0.1 multibasebox.test <your-other-hosts.test>
dnsmasq is available for a lot of linux distributions and it should be easy to install. Adapt your local config to sth similar.
- Move your project-folder into
projects
or clone a repository into that folder. - Your docker-container should use the environment-variables
VHOST
andVPORT
(defaults to 80) to signalize haproxy which hostname should be used and on which port the http-service is listening inside the container. There's no need to expose the ports to the host. See the documentation ofhaproxy-config
Phabalicious may help you to administrate your project and docker-setup. For more info visitfabalicious It can also new projects.
The containers are setup to restart automatically. If you encounter problems just run
bash setup-docker.sh
You can see the status of haproxy athttp://multibasebox.test:1936
Test if name resolution is working:
dscacheutil -q host -a name multibasebox.test
If you get an error message, try restarting mDNSResponder with
sudo killall mDNSResponder
or reboot the machine.
Still not working? Then try the/etc/hosts
-route.
About
Serve multiple docker container with the help of haproxy.