Skip to content

Instantly share code, notes, and snippets.

@gccpacman
Last active May 6, 2022 05:50
Show Gist options
  • Save gccpacman/cbf68fdd72b57222c6e7 to your computer and use it in GitHub Desktop.
Save gccpacman/cbf68fdd72b57222c6e7 to your computer and use it in GitHub Desktop.
Protecting the Docker daemon Socket with HTTPS

#Protecting the Docker daemon Socket with HTTPS

HOST-IP:172.17.42.1 VM-IP:172.17.0.2

openssl genrsa -aes256 -out ca-key.pem 2048
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem ```Common Name:  172.17.42.1```
openssl genrsa -out server-key.pem 2048
openssl req -subj "/CN=172.17.42.1" -new -key server-key.pem -out server.csr
echo subjectAltName = IP:172.17.42.1, IP:172.17.0.2, IP:127.0.0.1 > extfile.cnf
openssl x509 -req -days 365 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile extfile.cnf
openssl genrsa -out key.pem 2048
openssl req -subj '/CN=client' -new -key key.pem -out client.csr
echo extendedKeyUsage = clientAuth > extfile.cnf
openssl x509 -req -days 365 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile.cnf

rm -v client.csr server.csr

sudo docker -d --tlsverify --tlscacert=ca.pem --tlscert=server-cert.pem --tlskey=server-key.pem -H=172.17.42.1:2376


sudo docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem -H=172.17.42.1:2376 version

Running Docker with HTTPS - Docker Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment