'Change jenkins container deployment root path
I have pulled jenkins docker container to install on docker. It is working fine from functional perspectives. However, the URL to access jenkins is http://<host>:8080/
. I want this URL to be changed to http://<host>:8080/jenkins
.
docker run -d -p 8080:8080 -p 50000:50000 -u 0 -v /opt/jenkins:/var/jenkins_home jenkins
I did look at Jenkins website root path post but it did not help me to sort out the problem.
Solution 1:[1]
I'm using docker stack but it would be the same with docker-compose (same syntax) You pass the CLI arguments --prefix=/ci/dashboard in the JENKINS_OPT variable
Here is my jenkins.yml file:
version: '3.3'
services:
jenkins:
image: jenkinsci/jenkins
ports:
- 1080:8080
environment:
- JENKINS_OPTS="--prefix=/jenkins"
I deploy with
$ docker stack deploy -c jenkins.yml jenkins
Solution 2:[2]
- If you want to run jenkins in docker AND
- If you are coming from the official Jenkins docu here: https://www.jenkins.io/doc/book/installing/docker/
- You can add
--env JENKINS_OPTS="--prefix=/jenkins"
to the provideddocker run
command like:
docker run \
--name jenkins-blueocean \
--rm \
--detach \
--network jenkins \
--env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client \
--env DOCKER_TLS_VERIFY=1 \
--env JENKINS_OPTS="--prefix=/jenkins" \
--publish 8086:8080 \
--publish 50000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
myjenkins-blueocean:2.332.2-1
- If you are using apache2 you should leave there an entry like
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Proxy http://localhost:8086/jenkins*>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /jenkins http://localhost:8086/jenkins nocanon
ProxyPassReverse /jenkins http://localhost:8086/jenkins
ProxyPassReverse /jenkins http://your.host.com/jenkins
<Location /jenkins/>
ProxyPassReverse /
Order deny,allow
Allow from all
</Location>
Header edit Location ^http://your.host.com/jenkins/ https://your.host.com/jenkins/
Just like described here: https://www.jenkins.io/doc/book/system-administration/reverse-proxy-configuration-apache/
and here, e.g. for nginx or others:
https://www.jenkins.io/doc/book/system-administration/reverse-proxy-configuration-with-jenkins/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | pdem |
Solution 2 |