Skip to content

Instantly share code, notes, and snippets.

@prologic
Forked from philips/gist:7555876
Last active August 29, 2015 13:56
Show Gist options
  • Save prologic/8929120 to your computer and use it in GitHub Desktop.
Save prologic/8929120 to your computer and use it in GitHub Desktop.

Add a local docker unit file

Create a file called /media/state/units/docker-local.service that has the following contents:

[Unit]
Description=docker local

[Service]
PermissionsStartOnly=true
ExecStartPre=/usr/bin/systemctl kill docker.service
ExecStart=/usr/bin/docker -d

[Install]
WantedBy=local.target

Enable the local docker

sudo systemctl restart local-enable.service

Have fun!


All-In-One Script

cat - > /media/state/units/docker-local.service <<EOF
[Unit]
Description=docker local

[Service]
PermissionsStartOnly=true
ExecStartPre=/usr/bin/systemctl kill docker.service
ExecStart=/usr/bin/docker -d

[Install]
WantedBy=local.target
EOF
systemctl restart local-enable.service

All-In-One Script: Remote API Access

WARNING: This opens up the Docker Remote API to anyone! Be absolutely sure you have appropraitely firewalls in place on your network! YOU HAVE BEEN WANRED.

cat - > /media/state/units/docker-local.service <<EOF
[Unit]
Description=docker local

[Service]
PermissionsStartOnly=true
ExecStartPre=/usr/bin/systemctl kill docker.service
ExecStart=/usr/bin/docker -d -H unix:///run/docker.sock -H tcp://0.0.0.0:4243

[Install]
WantedBy=local.target
EOF
systemctl restart local-enable.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment