Reputation: 692
I have docker-compose.yml
like this:
version: '3'
services:
mysql:
image: mysql
volumes:
- data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=$ROOT_PASSWORD
volumes:
data:
And my mount point looks like: /var/lib/docker/volumes/some_app/_data
and I want to access data from that mount point and I'm not sure how to do it on Windows machine. Maybe I can create some additional container which can pass data from docker virtual machine to my directory?
When I'm mounting folder like this:
volumes:
- ./data:/var/lib/mysql
to use my local directory - I had no success because of permissions issue. And read that "right way" is using docker volumes.
UPD: MySQL container it's just example. I want to use such behaviour for my codebase and use docker foe local development.
Upvotes: 12
Views: 23602
Reputation: 24
When using WSL2 integration volumes are stored to \wsl$\docker-desktop-data\version-pack-data\community\docker\volumes.
It's possible to access the files directly with Windows Explorer.
But for my case path was:
\\wsl.localhost\docker-desktop-data\data\docker\volumes
.
Otherwise, you can use Explorer's search, type your volume's name and wait(~2 minutes for me, I have casual SSD).
Upvotes: 0
Reputation: 846
When using WSL2 integration volumes are stored to \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\
.
It's possible to access the files directly with Windows Explorer.
Testing with your mysql example, by creating a new Container:
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=not-secure -d mysql:latest
I get an new volume (directory) under the previously said path, where the mysql data resides under <volume-id>\_data
. Full path for example: \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\32475b20a9ddbf656ece0d00f33e35c543a4e08cd4ce108807b4952743a91ee1\_data\performance_schema
PS: I don't think it is recommended to copy paste or move data from your Windows system to that WSL-Network path. Permissions, line endings and ownership may not result in what you expect.
Upvotes: 0
Reputation: 36823
For Linux containers under Windows, docker runs actually over a Linux virtual machine, so your named
volume is a mapping of a local directory in that VM to a directory in the container.
So what you got as /var/lib/docker/volumes/some_app/_data
is a directory inside that VM. To inspect it you can:
docker run --rm -it -v /:/vm-root alpine:edge ls -l /vm-root/var/lib/docker/volumes/some_app/_data
total 188476
-rw-r----- 1 999 ping 56 Jun 4 04:49 auto.cnf
-rw------- 1 999 ping 1675 Jun 4 04:49 ca-key.pem
-rw-r--r-- 1 999 ping 1074 Jun 4 04:49 ca.pem
-rw-r--r-- 1 999 ping 1078 Jun 4 04:49 client-cert.pem
-rw------- 1 999 ping 1679 Jun 4 04:49 client-key.pem
-rw-r----- 1 999 ping 1321 Jun 4 04:50 ib_buffer_pool
-rw-r----- 1 999 ping 50331648 Jun 4 04:50 ib_logfile0
-rw-r----- 1 999 ping 50331648 Jun 4 04:49 ib_logfile1
-rw-r----- 1 999 ping 79691776 Jun 4 04:50 ibdata1
-rw-r----- 1 999 ping 12582912 Jun 4 04:50 ibtmp1
drwxr-x--- 2 999 ping 4096 Jun 4 04:49 mysql
drwxr-x--- 2 999 ping 4096 Jun 4 04:49 performance_schema
-rw------- 1 999 ping 1679 Jun 4 04:49 private_key.pem
-rw-r--r-- 1 999 ping 451 Jun 4 04:49 public_key.pem
-rw-r--r-- 1 999 ping 1078 Jun 4 04:49 server-cert.pem
-rw------- 1 999 ping 1675 Jun 4 04:49 server-key.pem
drwxr-x--- 2 999 ping 12288 Jun 4 04:49 sys
That is running an auxiliar container which has mounted the hole root filesystem of that VM /
into the container dir /vm-root
.
To get some file run the container with some command in background (tail -f /dev/null
in my case), then you can use docker cp
:
docker run --name volume-holder -d -it -v /:/vm-root alpine:edge tail -f /dev/null
docker cp volume-holder:/vm-root/var/lib/docker/volumes/volumes_data/_data/public_key.pem .
If you want a transparent SSH to that VM, it seems that is not supported yet, as of Jun-2017. Here a docker staff member said that.
Upvotes: 18