Skip to content

Instantly share code, notes, and snippets.

@sgdan
Created August 13, 2018 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgdan/3dbb39e33c781b9b5c855fa70f2a4a3a to your computer and use it in GitHub Desktop.
Save sgdan/3dbb39e33c781b9b5c855fa70f2a4a3a to your computer and use it in GitHub Desktop.
For local dev purposes, create a self-signed certificate and start Rancher 2 server container
# The Rancher 2 server container generates its own certificate but for some reason
# my browser wouldn't accept it, and didn't give me the option to override. Here's
# a way to generate a self-signed cert and use it to start the container.
# Note: I ran this on Git Bash shell in Windows 10, format for Linux may differ
# Generate certificate and key
openssl req -x509 -newkey rsa:4096 \
-keyout key.pem -out cert.pem \
-days 1000 -nodes \
-subj "//C=AU\ST=NSW\L=Sydney\OU=Org\CN=dockerlocal"
# Create volume and container (without starting)
docker volume create rancher_certs
docker container create --name=rancher \
--restart=unless-stopped \
-p 8080:80 -p 8443:443 \
-v rancher_certs:/etc/rancher/ssl \
rancher/rancher --no-cacerts
# Copy certs
docker cp key.pem rancher:/etc/rancher/ssl/key.pem
docker cp cert.pem rancher:/etc/rancher/ssl/cert.pem
docker cp cert.pem rancher:/etc/rancher/ssl/cacerts.pem # CA is the cert itself
docker start rancher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment