Skip to content

Instantly share code, notes, and snippets.

@ihucos
Created September 22, 2018 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihucos/6a0b50db19fe3b4796adee9172f5dab7 to your computer and use it in GitHub Desktop.
Save ihucos/6a0b50db19fe3b4796adee9172f5dab7 to your computer and use it in GitHub Desktop.
Run the docker daemon inside plash
#!/usr/bin/env plash-exec
--# usage: plash docker-daemon <DOCKER-ARGS>
--# Run the docker daemon inside alpine linux. Use the PLASH_DOCKER_SOCKET
--# environment variable to select the docker socket, the default is
--# '/tmp/docker.sock'. Note that '/var/run/docker.sock' is not shared between
--# containers and host, so it may not be appropriate as a socket
--#
--#
--# Example:
--#
--# $ sudo plash docker-daemon
--# INFO[2018-02-05T00:20:06.645188781Z] libcontainerd: new containerd process, pid: 19841
--# <snip>
--# INFO[2018-02-05T00:20:07.840933519Z] Daemon has completed initialization
--# INFO[2018-02-05T00:20:07.849471459Z] API listen on /tmp/docker.sock
--from
alpine
--apk
docker
--layer
--entrypoint-script
#!/bin/sh
# we need to "encapsulate" the socket. Docker creates it accesible by the docker
# group, but the gid inside the guest could be anything for the host (closes #8)
mkdir -p /tmp/plash-docker-wrap/
chown root:root /tmp/plash-docker-wrap/
chmod 600 /tmp/plash-docker-wrap/
export DOCKER_RAMDISK=1
exec dockerd -H unix://${PLASH_DOCKER_SOCKET:-/tmp/plash-docker-wrap/docker.sock}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment