running jenkins on localhost with SSL through Docker

Viewed 179

I want to run jenkins on localhost via docker with 2 conditions.

  1. I need port 443
  2. it should be https:// instead of http://

I tried everything, but I am still stuck with this issues.

This is the command I am using to run jenkins on port 443:

docker run -p 443:8080 -p 50000:50000 -v ~/jenkins_home:/var/jenkins_home jenkins/jenkins:lts

It transfers the port to 443, but does not make it HTTPS.
I have my cert and key from mkcert in root folder(/users/myname/). But I do not know how to transfer it to Jenkins configurations.

Is there a way to do it?

1 Answers

The Jenkins initial settings includes

  • --httpPort=$HTTP_PORT: To disable (because you’re using HTTPS), use port -1.
  • --httpsPort=$HTTPS_PORT: Uses HTTPS protocol on port $HTTPS_PORT.

So if you want to run Jenkins with HTTPS, you need:

  • to activate an HTTPS port (and map it)
  • to pass a self-signed certificate

You have a full example here, run with:

read -s -p "Keystore Password:" password
echo
sudo cp jenkins_keystore.jks /var/lib/docker/volumes/jenkins_home/_data

And:

docker run -d -v jenkins_home:/var/jenkins_home -v $(which docker):/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -p 443:8443 -p 50000:50000 jenkins/jenkins:lts --httpPort=-1 --httpsPort=8443 --httpsKeyStore=/var/jenkins_home/jenkins_keystore.jks --httpsKeyStorePassword=$password

Related