Access your Docker containers using domain names either with HTTP or HTTPS.
The Docker HostManager update your hosts
file and generate TLS certificates
when a container gets created with just a couple of labels.
# Run the docker manager
docker run --detach -t --name docker-hostmanager \
--restart always \
--volume docker-hostmanager-data:/data:rw \
--volume /etc/hosts:/host/etc/hosts:rw \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
gcanal/docker-hostmanager:latest
# Make your /etc/hosts/ writable
sudo chmod 777 /etc/hosts
# Run the docker manager
docker run --detach -t --name docker-hostmanager \
--restart always \
--volume docker-hostmanager-data:/data:rw \
--volume /private/etc/hosts:/host/etc/hosts:rw \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
gcanal/docker-hostmanager:latest
No tested yet, to be documented.
In order to access your domains using HTTPS, you will need to add the Root Certificate generated by DockerHostManager
in your browsers and in your trusted root certification authorities.
# Copy the certificate from a docker volume anywhere on your host machine
docker cp docker-hostmanager:/data/root-ca.crt .
Note: if you are using Firefox, you will need to add your certificate using the following method :
- Open
Preferences
- On the top right corner, search:
certificates
- Click on
View Certificates...
- Click on the
Authorities
tab - Click on
Import...
- Add your
root-ca.crt
- Tick the box
Trust this CA to identify websites.
- Click on
Ok
sudo cp root-ca.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates --fresh
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/root-ca.crt
certutil -addstore -f "ROOT" root-ca.crt
docker run --rm -t \
--label 'traefik.enable=true' \
--label 'traefik.port=80' \
--label 'traefik.backend=demo' \
--label 'traefik.frontend.rule=Host: nginx.docker' \
nginx:alpine
Head to http://nginx.docker or https://nginx.docker