Skip to content

Instantly share code, notes, and snippets.

@agmangas
Last active November 17, 2020 15:31
Show Gist options
  • Save agmangas/3f8e58655829c229d5bb986a2911a9d8 to your computer and use it in GitHub Desktop.
Save agmangas/3f8e58655829c229d5bb986a2911a9d8 to your computer and use it in GitHub Desktop.
Script to patch the default "runc" container runtime with a proxy that enables privileged access on Swarm nodes
#!/usr/bin/env bash
set -e
set -u
set -x
RUNC_PROXY_GIST="https://gist.githubusercontent.com/agmangas/905a3045074a8645462eadad95334b6a/raw/"
echo "## Adding runc proxy to enable privileged support"
wget -O /root/runc-proxy ${RUNC_PROXY_GIST}
chmod 755 /root/runc-proxy
cp /etc/docker/daemon.json /etc/docker/daemon.json.bak || true
if [ -f /etc/docker/daemon.json ];
then cat /etc/docker/daemon.json
else echo "{}"
fi \
| jq '.+ {"runtimes": {"runc-proxy": {"path": "/root/runc-proxy"}}, "default-runtime": "runc-proxy"}' \
| tee /etc/docker/daemon.json.new
mv /etc/docker/daemon.json.new /etc/docker/daemon.json
echo "## Restarting Docker service"
systemctl daemon-reload
systemctl restart docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment