Invalid mount config for type "bind": bind mount source path does not exist: /home/jenkins/.docker (Istio)
Asked Answered
R

7

10

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 
Rutabaga answered 20/4, 2020 at 6:14 Comment(2)
What is your infrastructure? You use docker-swarm? Have you tried to use -v instead of --mount, do you have any error then?Chitkara
Where is the docker engine (dockerd, as opposed to the docker CLI client) running, and does the directory exist there?Lammastide
C
14

As I mentioned in comments, workaround here could be to use

-v

instead of

--mount

Differences between -v and --mount behavior

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.

Chitkara answered 20/4, 2020 at 10:41 Comment(0)
G
5

this is permission issue . using docker desktop > settings > resources > file sharing >

and add your project directory path so docker engine can access it

Gadfly answered 14/2, 2023 at 8:23 Comment(3)
This was the most helpful answer for me, and it did fix my issue. On MacOS I have a symbolic link "projects -> /System/Volumes/Data/projects", and I added the "/System/..." to the File Sharing list without success. Then it occurred to me that I needed to add the value from $(pwd), so I added "/projects" ... now everything works.Grotius
@Grotius glad that solved your issue 🌹Gadfly
@evertjes welcome 🌹Gadfly
S
4

The error means that the filesystem isn't successfully shared into the docker container. For me, the fix was:

export TMPDIR=$PWD
Stomatitis answered 15/7, 2022 at 13:25 Comment(2)
Actually this answer is a great one. This solved my issue without having to get into changing the user who is assigned to the Docker daemon. For most situations, this will prevent you from getting into the topic of running Docker as a non-root user.Realist
I wonder what's the solution on Windows while using docker from testcontainers. The reason matches, the solution might be different...Exultant
B
2

The config in your docker-compose.yaml should be something as below:-

  volumes:
  - ~/docker-volumes/zk-single-kafka-single/zoo1/data:/data
  - ~/docker-volumes/zk-single-kafka-single/zoo1/datalog:/datalog

Now, Check the volume path which is actually present in your machine. It should be something as below:

/Users/akashverma/docker-volumes/zk-single-kafka-single

So both of them should match.

Britannia answered 7/6, 2021 at 9:52 Comment(0)
L
0

In Linux (Ubuntu) I got this message when I had running Docker Desktop and tried to start a DDEV container.
After shutting down Docker Desktop the DDEV container started without problems.

Luthern answered 7/4, 2023 at 7:40 Comment(0)
S
0

Docker Desktop, "Settings > Resources > File sharing > Virtual file shares."

Standley answered 14/9 at 17:27 Comment(0)
D
-1

In your specific scenario, when utilizing Docker Desktop, it's imperative to ensure that all the directories you intend to mount are explicitly registered with Docker Desktop under "Settings > Resources > File sharing > Virtual file shares." This step is crucial when utilizing the mount option to avoid encountering the error you mentioned.

Douche answered 28/1 at 4:55 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Mashhad

© 2022 - 2024 — McMap. All rights reserved.