Docker Desktop Windows 2.2.0.0 breaks "nested" volume mounting
Volumes mounted in a container which are inside a folder which is also a volume mount no longer have their content in the container. See the reproduction steps below for an example.
Steps to reproduce the behavior
Test Project Structure
- inner/
- inner-file.txt (empty dummy file)
- outer/
- outer-file.txt (empty dummy file)
- docker-compose.yml (see content)
docker-compose.yml
version: "3.7"
services:
centos:
container_name: nested_mount_test
image: centos
command: sleep 10m
volumes:
- ./outer:/test
- ./inner:/test/inner
- In the folder with docker-compose.yml file, run docker-compose up –d
- Run docker exec -it nested_mount_test /bin/bash
- Run cd /test and verify that there is a file called outer-file.txt and a folder called inner inside /test
- Observe the content of /test/inner
Expected behavior
When observing the content of /test/inner, it should container inner-file.txt
Actual behavior
When observing the content of /test/inner, it is empty
Information
In Docker Desktop 2.1.0.4, this works as expected, but after upgrading to Docker Desktop 2.2.0.0, the volume mounted inside another volume has no content.
- Windows Version: Windows 10 Version 1809
- Docker Desktop Version: 2.2.0.0
- Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM: No
Thanks for the report. We have code that is supposed to handle this in 2.2.0.0, but maybe it's not fully working. Could you please supply a diagnostics ID so that we can look into your logfiles?
#metoo
Diagnostics id 6002F307-2A0B-453A-B4BF-478422204896/20200122153448
Note that my setup is as documented at https://github.com/microsoft/vscode-remote-release/issues/2191
You probably want to look at around the 17:15 mark in my logs
We use this in all our node apps along with multi-stage builds for development, to keep the "node_modules" folder in the container and the source code on the host.
Dockerfile
FROM node:10-alpine AS dev-stage
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install -g npm@latest && npm install --no-audit
FROM dev-stage as testing-stage
COPY . /usr/src/app
docker-compose.yml
services:
web:
build:
context: .
dockerfile: Dockerfile
target: dev-stage
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
@houldsg Is the workflow you shared no longer working in 2.2? Or why did you share?
@cjancsar Correct. The workflow is broken with 2.2. It's the same "nested" volume mounting pattern except it's:
- container (/)
- host (/usr/src/app)
- container again (/usr/src/app/node_modules)
From our POV this is a major blocker. Virtually all our projects use this feature. Our usecase (simplified):
- ./html:/var/www/html
- 'path to some plugin':/var/www/html/plugins/pluginname/
@houldsg thanks, I think we are also experiencing that.
Also experiencing the same issue.
+1, What I found is the "child" volume would be created as an empty folder in the "parent" folder on the host. /var/www/app/web/assets/ would be created on the host (timestamp check) but empty.
volumes:
- ../../app/:/var/www/app/
- ../../assets/:/var/www/app/web/assets/
I'm seeing the same issue, same use case as @houldsg. I've had to downgrade to get some work done, but I did run diagnostics before doing so.
Diag ID: 7DB0481A-38FB-4150-A1C5-F752730ED428/20200123133355
The volumes are created and populated (node_modules), I can mount the volumes in a new container and see the contents, but they don't work nested under the bind mounted project root folder.
Here is one configuration for reference:
docker-compose.yml
version: '3.7'
client_dev:
volumes:
- type: volume
source: client-node_modules_dev
target: /home/nextjs/app/node_modules
- type: volume
source: client-cache_dev
target: /home/nextjs/app/.next
- type: bind
source: ./client
target: /home/nextjs/app
build:
context: ./client
dockerfile: Dockerfile.dev
networks:
net1:
aliases:
- client
networks:
net1:
name: project-name
volumes:
client-node_modules_dev:
client-cache_dev:
Dockerfile
FROM node:10-alpine
RUN mkdir -p /home/nextjs/app
WORKDIR /home/nextjs/app
COPY ./package*.json ./
RUN npm install
ENV NODE_ENV=development
EXPOSE 3000
CMD [ "npm", "run", "dev" ]
HEALTHCHECK --start-period=15s --interval=1m --timeout=5s CMD ["node", "healthcheck"]
We use this in all our node apps along with multi-stage builds for development, to keep the "node_modules" folder in the container and the source code on the host.
Dockerfile
FROM node:10-alpine AS dev-stage WORKDIR /usr/src/app COPY package*.json ./ RUN npm install -g npm@latest && npm install --no-audit FROM dev-stage as testing-stage COPY . /usr/src/appdocker-compose.yml
services: web: build: context: . dockerfile: Dockerfile target: dev-stage volumes: - .:/usr/src/app - /usr/src/app/node_modules
messing my head from last 2 hours, and realized that its an issue
We have found a simpler repro case and are investigating the issue. Repro is:
C:\Users\simon\repro> docker run --rm -v ~/:/test -v test-volume:/test/inner -it alpine touch /test/inner/data
C:\Users\simon\repro> docker run --rm -v ~/:/test -v test-volume:/test/inner -it alpine ls /test/inner/
data
C:\Users\simon\repro> docker run --rm -v ~/:/test -v test-volume:/test/inner -it alpine sh
/ # ls /test/inner/
/ # exit
(see that the last one does not find the data file).
Same issue here, seems pretty prevalent in 2.2.0.0. Started setting up a new local development workflow for a client and ran into this. Rolled back to an earlier version and it works, but isn't ideal getting a new workflow built on top of older version. Hopefully this one has some high priority. Thanks team!
We also have the same issue on all computers we updated… We'll roll back to the previous version while it's getting fixed
Also experiencing this issue when attempting to keep the container's node_modules separate.
i.e.
volumes:
- ./src/website:/home/app/website
- /home/app/website/node_modules/
I am excited to finally not have to use file polling in the 2.2 release but this is a major blocker.
Edit: I have tested this with WSL2 and it works as expected. (However there is an unrelated issue with file watching preventing us from using it)
Yep me too.
Stopped updating docker for like six months due to issues like this always popping up after updates, guess I'll have to go back to that strategy again, very frustrating.
@Cyral
there is an unrelated issue with file watching
We were experiencing something similar to that as well and linked it with this issue. Our development watch-mode typescript compilation time skyrocketed in 2.2
@cjancsar I can't figure out the watching issue and I haven't been able to find a github issue for it (or make a minimal example myself). Some file watching is working but not all of it - I spent hours and am at a loss. May be a WSL issue and not docker related though.
@krstffr Same. And downgrading is a PITA - still spending this morning trying to find an older bug free version of Docker so we can get up and running again. These kinds of issues seem to be very common, both in our dev workflow with compose and our CI.
Update: we think we've tracked this down, but it seems to be a Linux kernel bug(!), so we're being cautious about making the right change.
You can get an older version by uninstalling 2.2.0.0 and running choco install docker-desktop --version 2.1.0.5