Let's say you have your Keystore as jenkins_keystore.jks in the home folder of EC2 Ubuntu instance. Do this to generate one:
keytool -genkey -keyalg RSA -alias selfsigned -keystore jenkins_keystore.jks -storepass mypassword -keysize 2048
Now you'll easily set up Jenkins to run on https only while not making your own docker image:
Now, you can easily set up Jenkins to run on HTTPs while you are not making your own docket image:
docker run -v /home/ubuntu:/var/jenkins_home -p 443:8443 jenkins --httpPort=-1 --httpsPort=8443 --httpsKeyStore=/var/jenkins_home/jenkins_keystore.jks --httpsKeyStorePassword=mypassword
- -v /home/ubuntu:/var/jenkins_home Jenkins docker container gets the exposed host home folder.
- -p 443:8443 this will map Jenkins port 8443 in the container to the 443 port of the host
- --httpPort=-1 --httpsPort=8443 blocks jenkins http and exposes it with https on port 8443 inside the container
- --httpsKeyStore=/var/jenkins_home/jenkins_keystore.jks --httpsKeyStorePassword=mypassword provides your Keystore that has been mapped from the host home folder to the container /var/jenkins_home/ folder.