# Problem with named volume in docker-compose

**URL:** <https://forums.docker.com/t/problem-with-named-volume-in-docker-compose/98299>\
**Category:** Docker Desktop\
**Tags:** docker, macos\
**Created:** [September 3, 2020, 1:07am UTC](https://forums.docker.com/t/problem-with-named-volume-in-docker-compose/98299 "2020-09-03T01:07:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![skingsland](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/skingsland/32/28351_2.png) [@skingsland](https://forums.docker.com/u/skingsland)\
**Post date:** [September 3, 2020, 1:07am UTC](https://forums.docker.com/t/problem-with-named-volume-in-docker-compose/98299/1 "2020-09-03T01:07:59Z")

</div>

I’m having a problem getting a named volume to work locally in docker-compose. Here’s the docker-compose.yml I’m using:

```
---
version: "2.1"
services:
  my-service:
    image: alpine
    volumes:
      - alerts-volume:/var/folders
volumes:
  alerts-volume:
    #driver: local
    driver_opts:
      type: none
      o: bind
      device: /var/folders

```

When I run docker-compose up on that, I get the following error:

```
Creating network "steve_default" with the default driver
Creating volume "steve_alerts-volume" with default driver
Creating steve_my-service_1 ... error
ERROR: for steve_my-service_1 Cannot start service my-service: error while mounting volume '/var/lib/docker/volumes/steve_alerts-volume/_data': failed to mount local volume: mount /var/folders:/var/lib/docker/volumes/steve_alerts-volume/_data, flags: 0x1000: no such file or directory

```

It goes away when I un-comment the `"driver: local"` line. But that should be the default driver for volumes, so I don’t understand why that works. I’m using Docker version `19.03.13-beta2, build ff3fbc9d55` on Mac OS 10.14.6 (Mojave).

---

<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:** [September 3, 2020, 11:02am UTC](https://forums.docker.com/t/problem-with-named-volume-in-docker-compose/98299/2 "2020-09-03T11:02:53Z")

</div>

The claim Docker beeing easy and reliable to use is somehow only true on Linux systems…

Since Docker for Mac/Windows rely on a linux VM to run docker, the local driver is local to the vm. If you bind a host folder, it will be local to the vm as well. Though, you could use the local driver to mount NFS remote shares. Docker will mount the NFS share whenever the volume is used by a container and unmounted when the container stops.

Since you are on OSX, enabling NFS shares should be no challenge.

---

<div class="post-metadata">

**Author:** ![skingsland](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/skingsland/32/28351_2.png) [@skingsland](https://forums.docker.com/u/skingsland)\
**Post date:** [September 3, 2020, 2:15pm UTC](https://forums.docker.com/t/problem-with-named-volume-in-docker-compose/98299/3 "2020-09-03T14:15:24Z")

</div>

I don’t follow your point about mounting an NFS directory. The problem I’m seeing happens with mounting _any_ directory under `/var`; I only used `/var/folders` as an example.

To ask a different way: why do I need to specify `driver: local` for the volume? What other value does it have?

---

<div class="post-metadata">

**Author:** ![lucidbrot](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/lucidbrot/32/45996_2.png) [@lucidbrot](https://forums.docker.com/u/lucidbrot)\
**Post date:** [March 5, 2024, 4:34pm UTC](https://forums.docker.com/t/problem-with-named-volume-in-docker-compose/98299/4 "2024-03-05T16:34:42Z")

</div>

Thanks for this post! I just had the opposite issue and found the solution thanks to your issue.

docker run could mount the volume just fine, but docker compose dailed with “no such file or directory”. Explicitly specifying the `driver: local` in the `docker-compose.yaml` makes it work.

Windows 11, using WSL2.
