Frondor
Frondor

Reputation: 3466

Docker compose mounting empty volumes

Expected behavior

docker-compose up -d should properly mount the volumes

Actual behavior

Suddenly (it worked perfectly two days ago, didn't install anything nor updated OS), the volumes are no longer being mounted. Don't see any error message, only the container logs complaining that command can't find the file (because the "empty" volume overrides the container's copied files).

If I remove ./service:/home/node/api volume, then docker uses the files in the container and everything works fine.

Information

Already tried removing the docker machine from virtualbox and creating it again, pruning all volumes / images and containers. Even reinstalling Docker Toolbox, but issue persist.

Everything is ran with administrator rights.

More info

docker-compose config outputs

services:
  api:
    build:
      context: C:\users\fede\documents\test\service
    container_name: api
    ports:
    - 3000:3000/tcp
    volumes:
    - /c/users/fede/documents/test/service:/home/node/api:rw
version: '3.0'

$ docker inspect api outputs: https://pastebin.com/1zQ3vjFi

Files

I've simplified a sample app in order to make debug faster, you can see it here: https://github.com/Frondor/simple-node-app

I'm pretty new at docker, but if there's something else I can provide in order to start using docker locally again, just ask in the comments. But honestly, this started happening from one day to another without doing any changes to the system. No anti-virus involved.

Upvotes: 3

Views: 5804

Answers (1)

Frondor
Frondor

Reputation: 3466

For future reference, I finally found the reason why this started happening "suddenly". It has to do with the command line and relative paths of volumes not honoring the uppercase letters.

This

Notice the same path, but displayed diferently? That's product of my inexperience.

The first one works perfectly, and the VM maps the working directory to the shared volume without any problem. I guess it has to do with C:\Users\Fede having uppercase letters, which the second path doesn't honor.

So doing cd $HOME takes me to the ~ (home) path as seen here:

enter image description here

And now the terminal path is properly set to start mapping the host volume correctly.

$ docker-compose config

services:
  api:
    build:
      context: C:\Users\Fede\documents\test\service
    container_name: api
    ports:
    - 3000:3000/tcp
    volumes:
    - /c/Users/Fede/documents/test/service:/home/node/api:rw
version: '3.0'

Upvotes: 3

Related Questions