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 named haproxy-config will be pulled and started.
haproxy is listening on port 80 ond 443 and will forward all requests to a specific docker-image running inside the vm. It uses the hostname to distinguish the containers.
- Clone this repository,
- Run
bash ./setup-docker.sh
- Visit
http://multibasebox.test:1936
This will show you the haproxy status page.
Most likely you'll need a specialized fabfile.local.yaml
if you are using fabalicious. Here's a short example, adpat it to your setup and it should work:
dockerHosts:
mbb:
runLocally: true
rootFolder: <absolute-path-to-projects-folder>
hosts:
mbb:
xdebug:
remote_host: docker.for.mac.localhost
blueprint:
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.1 addn-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>
Move your project-folder into projects
or clone a repository into that folder.
Your docker-container should use the environment-variables VHOST
and VPORT
(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 of haproxy-config
Fabalicious may help you to administrate your project and docker-setup. For more info visit fabalicious
For scaffolding new projects have a look at our generator jaMann
The containers are setup to restart automatically. If you encounter problems just run bash setup-docker.sh
You can see the status of haproxy at http://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.