Docker device path differs depending on commands

409 Views Asked by At

After recent Docker update (Docker Desktop for Mac) my stack broke.

I'm using my docker-compose config in two ways - with up command and with run command to execute some operations via containers (when it's not up yet).

I'm getting error:

ERROR: Configuration for volume my_code specifies "device" driver_opt /Users/me/Projects/project/backend/my_code, but a volume with the same name uses a different "device" driver_opt (/host_mnt/Users/me/Projects/project/backend/my_code). If you wish to use the new configuration, please remove the existing volume "my_code" first:

I have configured docker-compose with volumes shared between containers.

volumes:
    my_code:
        driver: local
        driver_opts:
            type: none
            device: ${PWD}/project/backend/my_code
            o: bind

Looks like for some reason up and run commands get's different path from $PWD in docker-compose. One get's prefixed with /host_mnt and the other doesn't. Is this a bug or maybe my config is invalid?

Docker for Mac 2.4.0.0 stable Docker Compose 1.27.4 Catalina

1

There are 1 best solutions below

0
On

I just had the same issue with the prefix /host_mnt on a Ubuntu system.

This is something related to Docker Desktop.

The solution for me was to uninstall docker and Docker desktop according to the documentation

https://docs.docker.com/desktop/install/ubuntu/

https://docs.docker.com/engine/install/ubuntu/

And afterwards also delete the docker config files manually.

rm -rf ~/.docker

Then I just installed the docker engine instead of the docker desktop.

The problem was caused by an update on Docker Desktop that adds that /host_mnt prefix for compatibility with Windows users.