Skip to content

Instantly share code, notes, and snippets.

@markthebault
Last active September 1, 2016 15:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save markthebault/42981b77c1cfda83627da4c5a870f178 to your computer and use it in GitHub Desktop.
Save markthebault/42981b77c1cfda83627da4c5a870f178 to your computer and use it in GitHub Desktop.
inject custom certificate to docker-for-mac beta (1.12.0-rc4-beta20 build:10404)
#!/bin/bash
if [ "$#" -ne 2 ] || ! [ -d "$1" ]; then
echo "Usage: $0 /Path/To/Certificate CERT_NAME" >&2
exit 1
fi
# This assumes the cert is in the same directory as the script
source="$( cd $1 && pwd )"
# ca-certificate of the VM
destination=/etc/ssl/certs/ca-certificates.crt
# Send a new line to wake it up, then login as root with a blank password
cat <<HERE > ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
root
HERE
# Give it a second to get logged in, copy the cert and log back out
cat <<HERE > ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
mkdir -p $destination
cat $source/$2 >> $destination
service docker restart
exit
HERE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment