Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker version 2.0.0.0+ loses case sensitivity for filenames via volumes #5894

Closed
2 tasks done
RtypeStudios opened this issue Feb 27, 2020 · 14 comments
Closed
2 tasks done

Comments

@RtypeStudios
Copy link

  • I have tried with the latest version of my channel (Stable or Edge)
  • I have uploaded Diagnostics
  • Diagnostics ID: 9A51C6E0-B02C-4C2B-9409-B720C129F218/20200227075619

Expected behavior

On a mount to the host be able to create files in a case sensitive environment. Being able to create files both names "test" and "Test" in a mounted folder and have them treated as separate files. As it worked on 18.06.1

Actual behavior

When mounting a volume on windows in docker 18.06.1-ce-win73 2018-08-29 the mount would be case sensitive allowing both upper case file names and lower case as separate files.

root@148a0e8a7735:/app/tmp# echo "t" > test
root@148a0e8a7735:/app/tmp# ls
cache  restart.txt  test
root@148a0e8a7735:/app/tmp# echo "t" > Test
root@148a0e8a7735:/app/tmp# 

On Docker 2.0.0.0+ I get an error:

root@0eacc4ce3057:/app/tmp# echo "t" > test
root@0eacc4ce3057:/app/tmp# ls
cache  restart.txt  test
root@0eacc4ce3057:/app/tmp# echo "t" > Test
bash: Test: Input/output error

Information

  • Windows Version: Windows 10 Pro 1903
  • Docker Desktop Version: 2.2.0.3
  • Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM: No local desktop

Steps to reproduce the behavior

Install docker 2.0.0.0 on windows and use the following files, the go into the app container and cd into /app/tmp and run the commands above.

My docker compose:

version: '3.4'
services:

  db:
    container_name: 'test_db_1'
    image: 'postgres:10.11-alpine'
    environment:
        POSTGRES_DB: test_development
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: password
    ports:
      - "5432:5432"

  redis:
    container_name: 'test_redis_1'
    image: 'bitnami/redis:5.0'
    environment:
      ALLOW_EMPTY_PASSWORD: 'true'
      REDIS_DISABLE_COMMANDS: FLUSHDB,FLUSHALL
    ports:
      - "6379:6379"

  app:
    container_name: 'test_app_1'
    build:
      context: ./app
      dockerfile: dockerfile
    command: foreman start
    volumes:
      - ./app:/app
    ports:
      - "5000:5000"
    depends_on:
      - db

Docker File

FROM ruby:2.5.7

RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN apt-get update \ 
    && apt-get install -y --no-install-recommends apt-utils build-essential libpq-dev git imagemagick nodejs postgresql-client-9.6 ghostscript \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY . .
RUN gem update --system && gem install bundler --version "=1.15.2" # Specify bundler version to match Heroku
RUN bundle install
@stephen-turner
Copy link
Contributor

stephen-turner commented Feb 27, 2020

I confirm that on 2.2.0.3, you get an "input/output error". However, the behaviour on old versions is not as you describe ("the mount would be case sensitive allowing both upper case file names and lower case as separate files"). As the mounted volume is actually a Windows filesystem underneath, it is case insensitive, and we can't change that. In my experiments on old versions, "test" and "Test" are the same file, and you can address it under either name, which is also unexpected when you're in the Linux container. I'm not sure which is better, to have a case insensitive file system on Linux, which could lead to subtle bugs, or to give an error?

@thaJeztah
Copy link
Member

Looks like it's possible now to enable case-sensitive directories on Windows; https://www.howtogeek.com/354220/how-to-enable-case-sensitive-folders-on-windows-10/

@stephen-turner
Copy link
Contributor

Right, but I don't think Docker Desktop should forcibly do that, it would have to be something the user did for themselves.

@thaJeztah
Copy link
Member

Ah, sorry for my brevity; I was wondering; if the host location (windows) that's being bind-mounted is case-sensitive; does docker desktop respect that configuration? (so would -v C:\some \case-sensitive-directory\:/path/in/container work?

@RtypeStudios
Copy link
Author

Thank you for the replies gents,

However, the behavior on old versions is not as you describe ("the mount would be case sensitive allowing both upper case file names and lower case as separate files")

sorry yes, you appear to be right:

root@148a0e8a7735:/app/tmp# echo "1" > test
root@148a0e8a7735:/app/tmp# cat test 
1
root@148a0e8a7735:/app/tmp# echo "2" > Test
root@148a0e8a7735:/app/tmp# cat Test
2
root@148a0e8a7735:/app/tmp# cat test
2
root@148a0e8a7735:/app/tmp# ls
cache  restart.txt  test
root@148a0e8a7735:/app/tmp# 

Would using WSL resolve this? as WSL seems to support case sensitivity. Might be just a case of using the old version until WSL is stable.

WSL:

su@Laptop:~$ echo "1" > test
su@Laptop:~$ cat test
1
su@Laptop:~$ echo "2" > Test
su@Laptop:~$ cat Test
2
su@Laptop:~$ cat test
1
su@Laptop:~$ ls
Test  test

This issues does break rails development rather badly. As sprockets creates cache files and they end up clashing,. Before when no error was thrown things were okay, but now with the error happening rails breaks pretty badly.

@thaJeztah
Copy link
Member

As sprockets creates cache files and they end up clashing

Do you need those cache files on your host machine? If not, you could use a (named) volume for that path, instead of a bind-mount.

@thaJeztah
Copy link
Member

Looks like setting the directory to be case-sensitive; rails/sprockets#283 (comment)

or using a named volume rails/sprockets#283 (comment)

are solutions used by others

@RtypeStudios
Copy link
Author

thanks for those! I tried both of those solutions and neither were particularly good. The first one requires the fsutil and I had the same issue the guy posts below the one you point out. The second one I had troubles getting to work and feels like a bit of a hack to modify rails default behaviour. Also, ends up being a chunk I then need to alter every project I have to use. Where as before it worked on 18 without issue.

With the bind mount are you saying the I can bind sub-folder differently. For example /app could mount to the hosts c:\projects\test\ folder and use a name volume for /app/tmp that might be ideal as i really don't care about what goes on in the tmp folder.

@thaJeztah
Copy link
Member

thaJeztah commented Feb 28, 2020

With the bind mount are you saying the I can bind sub-folder differently. For example /app could mount to the hosts c:\projects\test\ folder and use a name volume for /app/tmp that might be ideal as i really don't care about what goes on in the tmp folder.

Yes, that should work, so

docker run -it --rm -v <host-path>:/app -v mycachevolume:/app/tmp <my container>

Or in a compose file;

version: "3.7"
services:
  app:
    image: myimage:latest
    volumes:
      - ./:/app
      - appcache:/app/tmp

volumes:
    appcache:

(If your local directory does not have a tmp dir, you will see an empty tmp directory appear on your local system, because the container needs a "mountpoint" to mount the volume on, and because you're bind-mounting your local directory in the container, which is mounted first, that directory is created inside the bind mount.)

@RtypeStudios
Copy link
Author

Thank you that indeed works. I wasn't aware you could map sub folders of another volume like that.

@thaJeztah
Copy link
Member

It's not "ideal" to nest mounts (and I think there have been some bugs/race-conditions about mount order in the past), but it should work, and using a named volume for caches should be more performant as well, because Docker Desktop doesn't have to sync those files back to the host filesystem (which can be a bottleneck if there's many files that are changing often).

@RtypeStudios
Copy link
Author

Great, thank you for that tip and for taking the time to help me out. Much appreciated and keep up the great work with Docker!

@stephen-turner
Copy link
Contributor

The fix for the original bug in this issue is now released in 2.2.0.4.

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Jul 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants