Skip to content

Instantly share code, notes, and snippets.

@smarterclayton
Created January 15, 2018 21:34
Show Gist options
  • Save smarterclayton/96ed352b67a58381863627ec4ebd6cb7 to your computer and use it in GitHub Desktop.
Save smarterclayton/96ed352b67a58381863627ec4ebd6cb7 to your computer and use it in GitHub Desktop.
Docker in pod
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: build-daemon
spec:
selector:
matchLabels:
app: build-daemon
template:
metadata:
labels:
app: build-daemon
spec:
containers:
- name: docker
image: openshift/origin-custom-docker-builder:latest
imagePullPolicy: IfNotPresent
command:
- /bin/bash
- -c
- |
#!/bin/bash
set -o errexit
rm -rf /usr/libexec/oci/hooks.d/*
exec dockerd-current --iptables=false --storage-driver=overlay2 --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --exec-opt native.cgroupdriver=systemd
securityContext:
runAsUser: 0
privileged: true
volumeMounts:
- mountPath: /run/systemd
name: host-run-systemd
- mountPath: /var/run/dbus
name: host-var-run-dbus
- mountPath: /sys/fs/cgroup
name: host-sys-fs-cgroup
- mountPath: /var/lib/docker
name: storage
volumes:
- name: host-run-systemd
hostPath:
path: /run/systemd
- name: host-var-run-dbus
hostPath:
path: /var/run/dbus
- name: host-sys-fs-cgroup
hostPath:
path: /sys/fs/cgroup
- name: storage
emptyDir: {}
@smarterclayton
Copy link
Author

oc rsh ds/build-daemon
docker run --detach --cgroup-parent=kubepods-besteffort-pod204df5fa_fa37_11e7_b592_525400cae48b.slice centos:7 sleep 1000

Results in

/sys/fs/cgroup/cpu,cpuacct/kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-pod204df5fa_fa37_11e7_b592_525400cae48b.slice/docker-dc1f8c66ad2c7510290482b2fb4a0e0ac8aa43b76ae59362cb6678eedb32625d.scope/kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-pod204df5fa_fa37_11e7_b592_525400cae48b.slice/docker-5e2c51a2426ac3189ffa620a620cd9087253e3d1e3c73c1616347007fa7a7a78.scope/tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment