Multiple webservices using docker-compose
behind nginx-proxy
Create a file to store your environment variables
# Email for letsencrypt cert renew
EMAIL=me@localhost.com
# You server's domain name
DOMAIN=localhost.com
At first you need to start the nginx
service, it includes nginx
, letsencrypt
and whoami
containers
docker-compose -p nginx -f docker-compose.yml up -d --force-recreate --remove-orphans
docker-compose -p code -f docker-code.yml up -d --build --force-recreate --remove-orphans
docker-compose -p gitlab -f docker-gitlab.yml up -d --force-recreate --remove-orphans
docker-compose -p jenkins -f docker-jenkins.yml up -d --force-recreate --remove-orphans
docker-compose -p netdata -f docker-netdata.yml up -d --force-recreate --remove-orphans
docker-compose -p portainer -f docker-portainer.yml up -d --force-recreate --remove-orphans
Generate new htpasswd, edit command
property on docker-portainer.yml
docker run --rm httpd:2.4-alpine htpasswd -nbB admin <password> | cut -d ":" -f 2
- If any password passed though cli has an
$
you must escape it using double$$
A simple docker-compose example combining Nginx, Node and Mongo, this works by itself and shouldn't run with the other nginx instance. This part was obtained from this post.
docker-compose -p node -f docker-node.yml up -d --force-recreate --remove-orphans
- See nginx running at: localhost
- See node app running at: localhost/node
Use cURL it works you'll see the something like I'm 999999999:
curl -H "Host: whoami.localhost.com" localhost
If you have Windows or macOS add the following on:
- macOS:
/etc/hosts
- Windows:
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost.com
127.0.0.1 code.localhost.com
127.0.0.1 whoami.localhost.com
127.0.0.1 gitlab.localhost.com
127.0.0.1 jenkins.localhost.com
127.0.0.1 netdata.localhost.com
127.0.0.1 portainer.localhost.com
127.0.0.1 wordpress.localhost.com
127.0.0.1 db.wordpress.localhost.com
Then visit whoami.localhost.com` with your favorite browser
- Follow this guide