This project contains a NGINX reverse proxy, consul, and registrator. When used together, they can create dynamic virtual host for any web container you launch.
This project requires that you are using the Docker Toolbox, which uses docker-machine with Virtualbox and Boot2Docker. It will not work on linux (unless you manually set a host IP of 192.168.99.100).
This means every new container (when lightly configured) you launch, will have a custom hostname you can pull up in your browser.
Yes. Really.
- Clone this repo.
- Run
make start
You need to add the following 5 lines to your service you want load balanced to docker-compose.yml
ports:
- 3000 #ensure this is the correct port your service exposes
labels:
- "SERVICE_3000_NAME=awesome-service" #adjust the port number here too, if needed
- "SERVICE_3000_TAGS=load-balance"
Note: the ports
line should NOT look like 3000:3000
. It should be a single port number only. This allows docker to assign a RANDOM port to bind to on the host. Consul / Registrator / NGINX will handle this random port without issue. This prevents you from experiencing port conflicts!
Now run docker-compose up
on your project.
Then simply go to http://awesome-service.tugboat.zone/
in your browser (because we set the name to be awesome-service
)
This project DOES provide SSL support (but needs to be enabled, see below). By default, it uses a self-signed certificate. You will receive a warning when you try to load https://container.tugboat.zone
, you can simply bypass the warning and continue.
The self-signed certificate likely will not work well for internal app-to-app communication since it will likely reject the cert. We personally just use http for that (it's internal anyways!), but you also have the option to use your own SSL certificate.
To use a custom configuration (enable SSL, custom SSL cert, custom domain) please run:
cp docker-compose.override.example.yml docker-compose.override.yml
and then edit to your needs.
Note: If you use a custom domain, you need to also setup wildcard
DNS to the IP 192.168.99.100
. So if you use the domain tugboat.ninja
, you need to setup *.tugboat.ninja
to point to 192.168.99.100
.
We own and have wildcard DNS set up for the following domains:
- tugboat.zone
- tugboat.ninja
- tugboat.tools
Are you a company where you want all of your devs to use the same custom configuration? Well we are too, so we have you sorted there as well!
Head on over to Tugboat Bootstrapper to learn how to create a repo with static configs
Well, we don't officially support linux as our setup makes an assumption you are using the Docker Toolbox. However you can still get it working. You either need to create a virtual network interface bound on 192.168.99.100
or edit this project to change it to use your host IP and the using a custom domain which wildcards to your custom IP. This is out of the scope of this tool, but its still possible.
A virtual network interface is your best option.
If you know of a good way to adapt this tool to work with linux, feel free to submit a pull request.
There are two causes of this:
- You are using a router that has "rebind production" turned on, you will need to turn that off, or add an exception for this domain. DD-WRT and Open-WRT often enable it by default.
- Your DNS server doesn't allow hostnames to resolve to local IPs (eg: 192.168.x.x). You can try using Google's DNS servers (8.8.8.8 and 8.8.4.4).
Tugboat relies on the fact that your VM is running on the default IP. Some situations can arise that cause it to use a different IP. There are two ways to fix this:
- Reboot your machine (not the VM).
- Run
docker-machine stop default
, ensure all virtualbox VMs are stopped, all virtualbox processes are stopped (including the GUI), and then run rundocker-machine start default
. If this doesn't work, see (1).
Docker beta uses the IP 127.0.0.1 instead of 192.168.99.100. So you will need to use the hostnames beta.tugboat.tld
which maps to 127.0.0.1.
See section Custom Configuration
above.
- Fork it ( https://github.com/articulate/tugboat/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- tecnobrat Brian Stolz - creator, maintainer