# Invalid mount config for type "bind"

**URL:** <https://forums.docker.com/t/invalid-mount-config-for-type-bind/138878>\
**Category:** Compose\
**Created:** [December 11, 2023, 10:15am UTC](https://forums.docker.com/t/invalid-mount-config-for-type-bind/138878 "2023-12-11T10:15:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrdkvv](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mrdkvv](https://forums.docker.com/u/mrdkvv)\
**Post date:** [December 11, 2023, 10:15am UTC](https://forums.docker.com/t/invalid-mount-config-for-type-bind/138878/1 "2023-12-11T10:15:16Z")

</div>

Hello,

Been searching now for a couple of hours without solution.

Updated to latest docker-compose and still having same issue:

```auto
ash-4.4# docker-compose --version
Docker Compose version v2.23.3

```

Docker is provided by Synology, Intel x86-64

```auto
ash-4.4# docker --version
Docker version 20.10.23, build 876964a
ash-4.4# uname -a
Linux ULTRA-NAS-1 4.4.302+ #69057 SMP Mon Nov 13 14:21:00 CST 2023 x86_64 GNU/Linux synology_denverton_1819+

```

Issue is build fails with following error:

```auto
ash-4.4# docker-compose up
[+] Running 0/0
 ⠋ Container rhel-ubi-9 Creating 0.0s 
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /volume1/docker/archive/rh9/rhel

```

Permissions:

```auto
ash-4.4# pwd
/volume1/docker/archive/rh9/rhel
ash-4.4# whoami
root

```

compose.yml

```auto
version: '3.7'

services:
  rhel:
    image: 'redhat/ubi9:latest'
    container_name: 'rhel-ubi-9'
    build:
      context: './rh9/root'
      dockerfile: '../Dockerfile'
      args:
        - 'img=redhat/ubi9:latest'
    volumes:
      - .:/test
      - type: bind
        source: '/volume1/docker/archive/rh9/rhel '
        target: '/rhel'
        read_only: true
    networks:
      - aux
    expose:
      - 22

networks:
   aux:

```

./rh9/Dockerfile

```auto
ARG img
FROM ${img}

RUN mkdir -p "/rhel"
VOLUME /rhel

ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

CMD ["/bin/bash"]

RUN rm -rf /var/log/*

RUN dnf -y install nginx; dnf clean all; systemctl enable nginx;

```

Docker is run as root, and has access to this valid directory…

Please correct this bug or enhance the error to correctly identify the issue.

Thank you.

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [December 11, 2023, 1:20pm UTC](https://forums.docker.com/t/invalid-mount-config-for-type-bind/138878/2 "2023-12-11T13:20:05Z")

</div>

> [@mrdkvv](#):
>
> ```auto
> Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /volume1/docker/archive/rh9/rhel
> 
> ```

Docker complains that the host path `/volume1/docker/archive/rh9/rhel ` (including the trailing space character that you also use in your compose file). Either the path exists without the trailing space, then delete the trailing space, or if the path does not exist, then create it.

---

<div class="post-metadata">

**Author:** ![mrdkvv](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mrdkvv](https://forums.docker.com/u/mrdkvv)\
**Post date:** [December 15, 2023, 4:22am UTC](https://forums.docker.com/t/invalid-mount-config-for-type-bind/138878/3 "2023-12-15T04:22:53Z")

</div>

[quote=“mrdkvv, post:1, topic:138878”]

…

Very true,

Understood – Sadly, this error may have also been preventing

volumes:  
- .:/test

where the /test folder also was not created … ???

---

<div class="post-metadata">

**Author:** ![mrdkvv](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mrdkvv](https://forums.docker.com/u/mrdkvv)\
**Post date:** [December 15, 2023, 4:24am UTC](https://forums.docker.com/t/invalid-mount-config-for-type-bind/138878/4 "2023-12-15T04:24:54Z")

</div>

I’ve marked the response as solved as my testing for the mount during “dockerfile” would always fail and is by design, where the mounts run “AFTER” the docker file that really surprised me as i would have thought the mounts would be available during setup… I guess only at run time ☹ And can’t find any documentation to set this expectation.

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [December 15, 2023, 6:44am UTC](https://forums.docker.com/t/invalid-mount-config-for-type-bind/138878/5 "2023-12-15T06:44:28Z")

</div>

Everything underneath the build element is used during build, and of course `image:` as it will become the name of the created image. The VOLUME instruction in a Dockerfile is merely a marker, that a path is supposed to be used as volume. If no volume is mapped against that container path during runtime, an anonymous volume will be created and used. Unlike the bind you configured, an anonymous volume can be listed by `docker volume ls`, the same way named volumes are listed. The error message you shared is a runtime error message, not a build error message, as docker compose doesn’t build images when they already exist, unless you append `--build` to the command or explicitly use `docker compose build`.

If you feel something is a bug, you can always create an issue in the respective project.

For docker daemon:

> **[Issues · moby/moby](https://github.com/moby/moby/issues)**
>
> The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems - Issues · moby/moby

For docker compose:

> **[Issues · docker/compose](https://github.com/docker/compose/issues)**
>
> Define and run multi-container applications with Docker - Issues · docker/compose
