Created
August 8, 2021 21:22
-
-
Save maynero/50d097fff04d2ff3c43f62f4b8572b68 to your computer and use it in GitHub Desktop.
Enable docker remote API using bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Absolute path of docker systemd file | |
dockersystemd='/lib/systemd/system/docker.service' | |
# Retrieve the line number of the ExecStart | |
execstartline=$(grep -n 'ExecStart=' ${dockersystemd} | cut -f1 -d':') | |
# New value of the ExecStart | |
newexecstart='ExecStart=/usr/bin/dockerd -H fd:// -H=tcp://0.0.0.0:2375 --containerd=/run/containerd/containerd.sock' | |
# Backup systemd file | |
cp -p ${dockersystemd} /tmp/docker.service.$(date '+%Y-%m-%d_%H%M%S').bak | |
# Update ExecStart with the new one | |
sed -i "${execstartline}s@.*@${newexecstart}@" ${dockersystemd} | |
# Reload and restart 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