I try to build istio
(1.6.0+) using Jenkins and get an error:
docker: Error response from daemon: invalid mount config for type "bind":
bind mount source path does not exist: /home/jenkins/.docker
the slave
contains .docker
directory:
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
parts of Istio
script
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?
❗️ I changed --mount
to -v
and error
disappeared
-v ${HOME}/.docker:/config/.docker
As I mentioned in comments, workaround here could be to use
-v
instead of
--mount
Because the -v and --volume flags have been a part of Docker for a long time, their behavior cannot be changed. This means that there is one behavior that is different between -v and --mount.
If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory.
If you use --mount to bind-mount a file or directory that does not yet exist on the Docker host, Docker does not automatically create it for you, but generates an error.
If you use docker swarm then it's well documented 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.
Worth to check this github issue comment.