I'm running Docker locally. I'm testing some functions from Jenkins and GitLab, so I ran:
For Jenkins:
docker run -d \
--add-host="gitlab.example.com:172.16.2.92" \
-p 8080:8080 -p 50000:50000 \
--name jenkins \
--restart always \
-v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
For GitLab:
docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 23:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
I don't have any problem exposing ports and accessing to the containers.
My problem
Both containers runs locally, my IP is 192.168.x.x and added GitLab's host to my hosts file, so when I try to access to GitLab, no problem. I type gitlab.example.com in the browser and vuola, GitLab's main page. I try to do the same with Jenkins adding host to docker.
docker run -d \
--hostname jenkins.example.com \
--add-host="gitlab.example.com:172.16.2.92" \
-p 8080:8080 -p 50000:50000 \
--name jenkins \
--restart always \
-v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
But I don't have any idea how to add the URL to my hosts file. I tried to add 192.168.x.x:8080 and jenkins.example.com but nothing. If I type jenkins.example.com in the browser nothing happends.
I found thta I can use nginx to do that binding but is not clear for me.
Anyone can help me to solve this problem?
Thanks!!