docker - 类型 "bind": bind mount source path does not exist:/home/jenkins/. docker (Istio) 的挂载配置无效

标签 docker jenkins jenkins-pipeline istio

我尝试构建 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-verror消失了
-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/

相关文章:

jenkins - 如何将 jenkins 管道中的 Jenkins 配置文件复制到 Web 服务器

jenkins - Helm Uninstall 删除版本(如果存在)

Azure Devops - 使用 docker 和 Azure 容器注册表 (ACR) 发布管道 - 标签问题

groovy - Jenkins 中 groovy jsonBuilder 出现间歇性堆栈溢出错误

bash - 将 Docker ENV 变量传递给 Rails 应用程序

ios - 向 Fabric 提交应用程序失败,错误代码为 0 或 502 或 503

java - 重新启动测试应用程序时 Jenkins 停止工作

jenkins - 如何查看 Pipeline 作业上的 Jenkins 工作区?

angular - 在远程服务器中 Dockerize Angular cli 应用程序

postgresql - Flask Postgres 与 Kubernetes 和 Docker 的连接失败