sha256:9d145da5f2bc9d2437e895a84e38627bf8b122e61b532d5243539004dde92d39
Last pushed
about 22 hours by sbx
Type
Sandbox Kit
Manifest digest
sha256:9d145da5f2bc9d2437e895a84e38627bf8b122e61b532d5243539004dde92d39
schemaVersion: "3"
displayName: Docker over TCP
description: Serve the sandbox's Docker Engine on TCP port 2375 and publish it on the host's loopback, so a Docker client on the host can run containers inside the sandbox.
version: 0.2.0
kind: mixin
provides:
- docker-tcp
requires:
- deb/curl
- deb/docker-ce
- deb/jq
capabilities:
- type: com.docker.sandbox/port@1
config:
container: 2375
name: docker-api
- type: com.docker.sandbox/lifecycle@1
config:
install:
- command: |
set -eu
cfg=/etc/docker/daemon.json
tcp=tcp://0.0.0.0:2375
command -v dockerd >/dev/null || { echo "docker-tcp: dockerd is not installed in this sandbox" >&2; exit 1; }
mkdir -p /etc/docker
[ -s "$cfg" ] || echo '{}' > "$cfg"
# An explicit "tls": false states the intent to serve without TLS.
# Without it, dockerd delays its start by about 15 seconds to warn,
# and says a later release will refuse to start at all. A TLS
# setting of the user's own is left alone.
jq --arg tcp "$tcp" '
.hosts = (((.hosts // []) + ["unix:///var/run/docker.sock", $tcp]) | unique)
| if has("tls") or has("tlsverify") then . else .tls = false end
' "$cfg" > "$cfg.tmp"
if [ "$(cat "$cfg")" = "$(cat "$cfg.tmp")" ]; then rm -f "$cfg.tmp"; else mv "$cfg.tmp" "$cfg"; fi
description: Make dockerd listen on tcp://0.0.0.0:2375 as well as the unix socket.
user: root
startup:
- command: |
set -eu
n=0
until curl -sf --max-time 2 http://127.0.0.1:2375/_ping >/dev/null 2>&1; do
n=$((n + 1))
if [ "$n" -ge 60 ]; then
echo "docker-tcp: dockerd is not listening on tcp://0.0.0.0:2375" >&2
tail -n 30 /var/log/dockerd.log >&2 || true
exit 1
fi
sleep 0.5
done
description: Check that dockerd answers on tcp://127.0.0.1:2375.
user: root