我尝试构建 istio
( 1.6.0+ ) 使用 Jenkins 并得到一个错误:
docker: Error response from daemon: invalid mount config for type "bind":
bind mount source path does not exist: /home/jenkins/.docker
slave
包含 .docker
目录:13:34:42 + ls -a /home/jenkins
13:34:42 .
13:34:42 ..
13:34:42 agent
13:34:42 .bash_logout
13:34:42 .bash_profile
13:34:42 .bashrc
13:34:42 .cache
13:34:42 .docker
13:34:42 .gitconfig
13:34:42 .jenkins
13:34:42 .m2
13:34:42 .npmrc
13:34:42 .oracle_jre_usage
13:34:42 postgresql-9.4.1212.jar
13:34:42 .ssh
13:34:42 workspace
Istio
的一部分脚本export CONDITIONAL_HOST_MOUNTS=${CONDITIONAL_HOST_MOUNTS:-}
if [[ -d "${HOME}/.docker" ]]; then
CONDITIONAL_HOST_MOUNTS+="--mount type=bind,source=${HOME}/.docker,destination=/config/.docker,readonly "
fi
"${CONTAINER_CLI}" run --rm \
-u "${UID}:${DOCKER_GID}" \
--sig-proxy=true \
${DOCKER_SOCKET_MOUNT:--v /var/run/docker.sock:/var/run/docker.sock} \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
$CONTAINER_OPTIONS \
--env-file <(env | grep -v ${ENV_BLOCKLIST}) \
-e IN_BUILD_CONTAINER=1 \
-e TZ="${TIMEZONE:-$TZ}" \
--mount "type=bind,source=${PWD},destination=/work" \
--mount "type=volume,source=go,destination=/go" \
--mount "type=volume,source=gocache,destination=/gocache" \
${CONDITIONAL_HOST_MOUNTS} \
-w /work "${IMG}" "$@"
... Have you tried to use -v instead of --mount, do you have any error then?
❗️我改了
--mount
至-v
和 error
消失了-v ${HOME}/.docker:/config/.docker
最佳答案
正如我在评论中提到的,这里的解决方法可能是使用-v
而不是 --mount
-v 和 --mount 行为之间的区别
因为 -v 和 --volume 标志长期以来一直是 Docker 的一部分,所以它们的行为无法更改。这意味着 -v 和 --mount 之间存在一种不同的行为。
如果使用 -v 或 --volume 绑定(bind)挂载 Docker 主机上尚不存在的文件或目录, -v 为你创建端点 .它始终创建为目录。
如果使用 --mount 绑定(bind)挂载 Docker 主机上尚不存在的文件或目录, Docker 不会自动为您创建它,但会生成错误。
如果您使用 docker swarm,那么它有据可查 here
If you bind mount a host path into your service’s containers, the path must exist on every swarm node. The Docker swarm mode scheduler can schedule containers on any machine that meets resource availability requirements and satisfies all constraints and placement preferences you specify.
值得检查 github issue comment .
关于docker - 类型 "bind": bind mount source path does not exist:/home/jenkins/. docker (Istio) 的挂载配置无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61316142/