产品动态
公告
产品发布记录
/var/run/docker.sock)作为 hostPath 挂载到 CI/CD 的业务 Pod 中,之后在容器里通过 UNIX Socket 来调用宿主机上的 Docker 进行构建。该方式操作简单,比真正意义上的 Docker in Docker 更节省资源,但该方式可能会遇到以下问题:docker exec 接口操作其他容器。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 路径,可以指定其他路径。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
文档反馈