-
Notifications
You must be signed in to change notification settings - Fork 64
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
Populating a volume using a container does not work in Docker on Windows #40771 #369
Comments
There is already a document link for this in the original thread? https://docs.docker.com/engine/reference/builder/#notes-about-specifying-volumes |
FYI @ritikaguptams |
Hi @windymindy, |
Hey. The steps are described in The idea, once again, is that one is able to pick out data from the container. Maybe, override some of it, for instance a configuration file, and put it back. This is how named docker volumes are mostly used on linux. But as the note warns (thanks for finding it), the target inside the container should be empty. The reason I made this ticket is that I was wondering if there is some major limitation that prevents from implementing the behaviour. |
This issue has been open for 30 days with no updates. |
3 similar comments
This issue has been open for 30 days with no updates. |
This issue has been open for 30 days with no updates. |
This issue has been open for 30 days with no updates. |
This issue has been open for 30 days with no updates. |
3 similar comments
This issue has been open for 30 days with no updates. |
This issue has been open for 30 days with no updates. |
This issue has been open for 30 days with no updates. |
I've added "pre-populating named volumes" to our backlog of feature requests. If we have a chance in the future, we'll try to incorporate this ask into our plans. Since we don't have a current timeline to share, I'll close this Issue. |
To provide additional context to future viewers, you can pre-populate volumes in both Linux and Windows Docker containers but you'll have to approach them in different ways. Linux Docker ContainersFor Linux Docker containers, we can create a volume, use a temporary container to populate it, and hook it up to the container. That, or any other container, can have access to the contents of the volume. We do this through the following commands:
docker volume create my-vol
docker volume ls
docker volume inspect my-vol
cd foo
echo hi > a.txt
tar -C /Users/Desktop/foo -c -f- . | docker run --rm -i -v my-vol:/data alpine tar -C /data -xv -f- Important Make sure you specify
docker run -v my-vol:/data -it --name bar alpine Note Make sure Docker Desktop is set to "Use Linux Containers" and you've pulled the image
$> data ls
a.txt Note If Windows Docker ContainersFor Windows Docker containers, we can only create an empty volume and attach it to a container. The container can populate it but it does not start out pre-populated like Linux containers can do. There is a way to emulate this behavior however.
docker volume create my-vol
docker volume ls
docker volume inspect my-vol
cd foo
echo hi > a.txt
docker run --rm -v C:\Users\Desktop\foo:C:\foo -v my-vol:C:\data -it mcr.microsoft.com/windows/servercore:ltsc2022 Note
$> dir
02/05/2024 02:26 PM <DIR> data
02/05/2024 01:51 PM <DIR> foo
... other folders
$> Xcopy C:\foo C:\data /E /H /C /I
1 File(s) copied
$> exit
docker run -v my-vol:C:\data -it mcr.microsoft.com/windows/servercore:ltsc2022
$> dir
02/05/2024 02:26 PM <DIR> data
$> dir data
02/05/2024 02:23 PM a.txt |
Hello.
Could this possibly be in scope of this project?
moby/moby#40771
When using Docker Desktop in the Windows Containers mode named volumes render directories empty.
I found it very confusing that named volumes prepopulating behaviour is Linux only.
And I did not seem to find it mentioned anywhere in the documentation.
Thank you.
The text was updated successfully, but these errors were encountered: