/var/run/docker.sock) as the hostPath to the CI/CD service Pod, and then call the Docker of the host through the UNIX Socket to build image in the container. This method is simple and can save more resources than running a Docker host inside of another Docker host (Docker in Docker). However, this method may encounter the following problems:docker exec interface.apiVersion: v1kind: Podmetadata:name: clean-cispec:containers:- name: dindimage: 'docker:stable-dind'command:- dockerd- --host=unix:///var/run/docker.sock- --host=tcp://0.0.0.0:8000securityContext:privileged: truevolumeMounts:- mountPath: /var/runname: cache-dir- name: clean-ciimage: 'docker:stable'command: ["/bin/sh"]args: ["-c", "docker info >/dev/null 2>&1; while [ $? -ne 0 ] ; do sleep 3; docker info >/dev/null 2>&1; done; docker pull library/busybox:latest; docker save -o busybox-latest.tar library/busybox:latest; docker rmi library/busybox:latest; while true; do sleep 86400; done"]volumeMounts:- mountPath: /var/runname: cache-dirvolumes:- name: cache-diremptyDir: {}
/var/run path on the node, you can specify other paths.apiVersion: apps/v1kind: DaemonSetmetadata:name: docker-cispec:selector:matchLabels:app: docker-citemplate:metadata:labels:app: docker-cispec:containers:- name: docker-ciimage: 'docker:stable-dind'command:- dockerd- --host=unix:///var/run/docker.sock- --host=tcp://0.0.0.0:8000securityContext:privileged: truevolumeMounts:- mountPath: /var/runname: hostvolumes:- name: hosthostPath:path: /var/run
apiVersion: v1kind: Podmetadata:name: clean-cispec:containers:- name: clean-ciimage: 'docker:stable'command: ["/bin/sh"]args: ["-c", "docker info >/dev/null 2>&1; while [ $? -ne 0 ] ; do sleep 3; docker info >/dev/null 2>&1; done; docker pull library/busybox:latest; docker save -o busybox-latest.tar library/busybox:latest; docker rmi library/busybox:latest; while true; do sleep 86400; done"]volumeMounts:- mountPath: /var/runname: hostvolumes:- name: hosthostPath:path: /var/run
Feedback