How can I map a shared folder from my container on Mac? - macos

I have a folder insider a Docker container that is shared through Samba. I can map this folder on Windows without problem running something like:
net use z: \\vm_ip\folder
In the case above, z: is the drive that I created with the content from the shared folder.
How could I map that same folder on Mac?

Step 1 - Sharing folder using Samba
The first thing that you need to do is let the folder that contains the files (project, source codes, settings, etc) that you want to share, visible for MacOS.
To do that, you'll need to share the folder on Docker Container using Samba. I won't describe how to do this here because there are a lot of resources on Internet.
Step 2 - Redirecting the Samba ports on Kitematic
Kitematic is a platform that helps you to configure the container and other settings on Docker. It can be downloaded here: https://www.docker.com/products/docker-toolbox. You DON'T need Kitematic to create the rules to redirect the Samba ports, however, you won't spend 2 minutes for that (instead trying to discover how to do that in the CLI).
Having Kitematic installed on MacOS:
Start Kitematic;
Select the container (panel on left with the title Container) that contains the folder that you shared using Samba;
Image of Panel on Docker
Click on the Settings tab and then the select the tab below called Hostname/Ports
Image of Settings panel on Docker
Now, we add the ports 137, 138, 139 and 445 and redirects it to the same port on localhost.
Step 3 - Mounting the Samba shared folder on MacOS
The last thing that is needed to edit your files on MacOS,is just map on MacOS the folder that is shared on Samba (inside the Docker container). To map that, open the terminal and run the following command:
$ mount_smbfs //guest#localhost:/SharedFolderOnSamba source/
What we're doing is using the method mount_smbfs, telling that we'll connect to the #localhost in the folder SharedFolderOnSamba using the user guest and then, we'll map (create a new Drive) in the source/ folder on the currenct directory of you terminal session on MacOS.
So, pay attention:
You can use any other user to use instead guest;
You must have a source/ folder or define another folder that will be used;
The SharedFolderOnSamba must be change to the name of the folder that you've shared using Samba. To confirm the name of the folder, go to /etc/samba/ and open smb.conf and search by the folder that you've shared.

If you are using Docker For Mac, the /Users folder from your mac is already mounted inside the virtual machine inside the Docker For Mac application runs. It is accessible via /Users inside the vm. That means you can do: docker run -v /Users/some/path:/folder ... in the container's /folder will meant to /Users/some/path in the vm, which maps back to your mac's /Users/some/path.
If you want some other location other than /Users, click on the whale icon at the top of your screen, choose Preferences, and then click on the File Sharing tab. If you have mounted a samba/cifs share somewhere on your mac, you can add that path here.

Related

How to know the folder path where is my laravel project in docker with WSL2

excuse me for my English.
Long time ago, I installed a laravel project with docker in windows 10 with WSL2 using DEBIAN; now, I want to resume it, i.e I want to continue developing the project. My problem is that I do not know where is that project folder in Debian.
The above image show the docker image runnig.
I want to locale my project folder in debian, and continue developing the project, so ¿how Do I do this?
First click on CLI icon on your app docker container (fastfoot-api_laravel.test_1):
And enter pwd command (this will most likely be the project directory, something like: /app, /var/www/app, etc.). Alternatively, you can try to find / -name "composer.json".
Then open windows file exporer, click in address input and type \\wsl$.
After this navigate to your docker container (probably "debian*" name) and to the previously found folder structure (/var/www/.. etc.)

How to change Docker Image location on Windows 10 Home [duplicate]

I am using docker toolbox on Windows 7 to run docker. (docker version 1.9.1)
As it turns out, the docker machine creates its VM at C:\Users\username\.docker\machine\machines\default. As I commit the images, the size of VM at this location bloats up. Since it's Windows, I can't afford the luxury of space on the C drive.
Is there any way I can change the location of the default machine?
You can move .docker directory to another drive and create a junction point to it.
Please note that regular shortcut will not work.
For example:
Move .docker directory from C:\Users\username to D:\
and run:
C:\Users\username>mklink /j .docker D:\.docker
Junction created for .docker <<===>> D:\.docker
This is what worked perfectly for me on Windows 7:
Setup the MACHINE_STORAGE_PATH environment variable as the root of the location you want to use for the Docker machines/VMs, cache, etc.
Install Docker Toolbox
Run Docker Quickstart Terminal
Docker Toolbox will now create all the files at the location pointed at by MACHINE_STORAGE_PATH.
UPDATE:
Note that creating a new VM with the new storage path is not ideal, as the Docker Quickstart Terminal scripts don't seem to work with anything not named "default".
If you've already got a VM sitting in the C: drive, then the simplest thing to do would be to go to Oracle VirtualBox and delete the "default" VM, uninstall Docker Toolbox, delete C:\Users\<username>.docker\, and then follow the 3 steps above.
Note: uninstalling and reinstalling Docker Toolbox may not be required. But I haven't tested without it.
Update
To move Docker certificates also, set the DOCKER_CERT_PATH variable to point to the path of the new drive. Thanks to #Nutle for the tip.
Since 2015, there is now (June 2017) Hyper-V, which allows you to define where you want your VHDX files:
See Docker for Windows 1.13.0, 2017-01-19 (stable):
VHDX file containing images and non-host mounted volumes can be moved (using “advanced” tab in the UI)
That will modify the %APPDATA%\Docker\settings.json with a line:
"MobyVhdPathOverride":"C:\\Users\\Public\\Documents\\Hyper-V\\New folder\\MobyLinuxVM.vhdx"
See this thread for more.
Original answer
Currently 2015 , docker-machine forces the use of %USERPROFILE%:
See libmachine/mcnutils/utils.go#L17-L25
As commented in issue 499:
In the meantime, how will users be able to specify where the .docker/machine/* files are stored?
you can by specifying --storage-path on the command line or using the environment variable MACHINE_STORAGE_PATH.
(You can see it implemented in PR 1941)
Joost Den Boer points out in the comments
Just tried '-s <path>' on a Mac and it seems to work fine.
What might not be obvious is that the path option goes before the command.
Running "docker-machine -s /Volumes/other/location' create --driver=virtualbox" created a new VirtualBox image at the other location.
Simply use the VirtualBox graphic interface to relocate the file disk.vmdk:
Copy file C:\Users\{myUsername}\.docker\machine\machines\default\disk.vmdk into another folder, say F:\docker-image\.
Open VirtualBox, select default VM and open Settings.
Open Storage, select current disk.vmdk and release it (or delete it).
Click on Choose Virtual Hard Disk File... and search for copied file in F:\docker-image\
A Warning occurs: VirtualBox complains of old VM UID then go to menu File, select Virtual Media Manager... and release or remove old disk.vmdk
Retry 4., it's done!
If required by your environment then do the relocation also for boot2docker.iso, Snapshot Folder, Video Capture.
Put these two commands when running docker quick start terminal.
I suppose that your new location is "D:\docker" and your new machine name is "docker1"
export MACHINE_STORAGE_PATH=D:\\docker
docker-machine create --driver=virtualbox docker1
This should create a new machine with specified name in your new location.
I could not get the MACHINE_STORAGE_PATH environment variable method working. It kept complaining about missing certificates when first initialising the machine. Still on Windows 7 so have to use docker-toolbox.
I got around the issue by:
Uninstalling Docker Toolbox and restarting machine
Open up Administrator prompt (Find command prompt, hold shift, choose "Run As Administrator")
Deleting .docker from %USERPROFILE%: rmdir /S %USERPROFILE%.docker
Create folder called .docker elsewhere: mkdir a:\.docker
mklink /J %USERPROFILE%.docker a:\.docker
Close Admin command prompt
Reinstall Docker Toolbox
Use the Docker Quickstart Terminal link to bootstrap everything.
Kitematic can be opened now too (though I had to choose the "Use Virtual Box" option on first error.
I have had a bit of trouble with any of the solutions above but this is what worked for me:
define the MACHINE_STORAGE_PATH environment variable to point to your desired
directory/folder.
Install docker-toolbox as normal, if this works for you then fine, but for me it was still installing inside .docker directory.
To fix this I have then stopped and removed the default machine that was created along with .docker folder from the Users directory.
Edited the start.sh script and added the line at the top:
e.g.
export MACHINE_STORAGE_PATH=D:\\Docker
Run the Docker Quickstart Terminal Shortcut, which rebuilt the default machine inside the desired folder
This answer is for people using Docker Toolbox (Windows 10 Home Build 1909, You can follow below steps for docker installation and then location change. I am not adding any images)
Install Docker Toolkit and VM must be installed with Admin Privileges after the installation of docker toolkit (*because Docker Toolkit also installs VM but it's of lower version and creates a problem with other iso files, u can uncheck also, in that case, *). Now we have to change the location of disk.vmdk and update the new location in VM.
Install Docker Toolbox from here. Follow the instructions provided
Now Download Virtual Machine v6+
Install Virtual Machine as Administrator (By Right-clicking and selecting there)
Goto place where your VirtualBox.exe(Not the installer) is present and right-click on it (you can find from the shortcut created on your Desktop)
goto properties --> compatibility --> change setting for all users --> select run this program as administrator
Now close the VM if it's running and run the Kitematic, If it fails (it will probably) then select option provided related to VM (only 2 options are there)
This time it will work, now close it
Changing the Location where Images will be downloaded
open your VM and close a newly running image default (right-click -> close --> power off)
copy paste your disk.vmdk file (for me it's present at C:\Users\Dell\.docker\machine\machines\default\disk.vmdk) to a place where you want to store your images that you download (basically disk.vmdk is what will grow in size when you are using docker)
Now we need to tell the VM also about this change
Right-click default image and goto settings
Select Storage
remove disk.vmdk attachment by right-clicking --> remove (that was the older path binded disk.vmdk)
click on file --> virtual media manager and remove disk.vmdk from here also (Now VM don't know if such a disk.vmdk thing exsists)
Right-click default image --> storage --> add hard disk (this option is just above that iso image)
Now select that disk.vmdk that you have pasted somewhere
Now run your docker cli and then run this command docker run hello-world
If no error is there then it's all done
You can verify size by checking the sizes of those two vmdk disks and then pulling some new images
I have written a very descriptive answer starting from installation because I did face some issues and so wanted to make it highly straight forward for the others.
You can delete your disk.vmdk disk (older one) from your C drive if you want to
Create file called c:\programdata\docker\config\daemon.json with content below where e:\images is location where do you want to store all you images etc. restart docker.
{
"graph": "e:\\images"
}
This Worked like a charm
Reference - https://forums.docker.com/t/where-are-images-stored/9794/11
These answers are out of date, as of the latest release. The location is configurable in the Settings user interface.
https://github.com/docker/for-win/issues/333
I found lots of these answers were out of data, at least they did not work in my environment: win10 PRO, docker desktop community 2.0.0.3. Finally, I resolved this problem by this method:
uninstall docker
open Hyper-V manager (press WIN key and then enter "Hyper")
Change the default virtual hard disk locations in the Hyper-V settings (not on the VM settings) and confirm
install docker
check the disk image location in advanced options of docker settings
I use windows 10 and Docker desktop (community) Version 2.0.0.0, I want to move vhdx file to another Drive.
Right click over Docker Desktop -> Settings
then the Docker Desktop UI will open go to Advance -> Disk image location
just change the path to new destination, the whole process was smooth and fast for me - it's automatically copy the vhdx file from original path to new path restart docker and all work as expected
 
For windows 7:
copy paste your disk.vmdk file (for me it's present at C:\Users\name.docker\machine\machines\default\disk.vmdk) to a place where you want to store your images that you download (basically disk.vmdk is what will grow in size when you are using docker)
in Virtualbox Right-click default image and goto settings
Select Storage remove disk.vmdk attachment by right-clicking --> remove
click on file --> virtual media manager and remove disk.vmdk from here also
Right-click default image --> storage --> add hard disk (this option is just above that iso image)Now select that disk.vmdk that you have pasted somewhere
change now this path in config.json (C:\Users\name.docker\machine\machines\default\config.json)
change the storage path with this new one where u put the location of your hard disk ( "StorePath": "F:\docker-image")
save.

How to files form docker container to host in windows containers

I am learning docker. In my image build process i create a file called "appsettings.json" in a folder called "Config". I want this file to be editable by the user outside the container. The final goal is that a user can stop the container, make changes to the settings file and start the container again with the new settings file.
I am using windows containers on a windows 10 host. I created a new volume first:
docker volume create myvolume
After that I tried to start my container
docker run -v myvolume:C:/app/Config
However, it seems that the -v argument deletes all content in the Config folder. I was aware that bind mounts override folders in the container with folders on the host, but I thought this named volume will copy the appsettings file to the host.
What I could do is creating the volume first, starting the container and copying the file from within the container into the volume, but this seems to be an annoying overkill.
Is there any easier way or best practice to make files which result as part of the build process visible to the host file system?
you can't mount files from your host machine into volumes. Like Pandey Amit already mentioned in the comments, you have to mount the Config directory of your host machine directly into the container. To achieve this in Windows 10, you have to grant the access to your filesystem in the docker settings first.
Open Docker Dashboard -> Settings -> Resources -> FILE SHARING + add here the directory, which should be mounted in your Docker containers (fyi: all the subdirectories are included)
I recommend to restart docker itself, to take note of the new settings.
Once docker has restarted, run your container:
docker run -v C:/app/Config:/path/to/your/app/Config <image-name>
This will mount the content of C:\app\Config into the container and now you should be able to modify the content of appsettings.json even without having to restart your container (but this depends on the architecture of your application -> if it supports a live reload of appsettings.json)
UPDATE: you cannot mount files from your docker image on a host machine. if you want, you could instruct the user to create the file manually on the host machine and follow with the steps described above. But if the only thing you want achieve, is to allow the user to override application settings I would recommend you to work with environment variables. For example run container with overwritten setting from the host machine:
docker run -e "foo=bar" <image-name>

Change Docker machine location - Windows

I am using docker toolbox on Windows 7 to run docker. (docker version 1.9.1)
As it turns out, the docker machine creates its VM at C:\Users\username\.docker\machine\machines\default. As I commit the images, the size of VM at this location bloats up. Since it's Windows, I can't afford the luxury of space on the C drive.
Is there any way I can change the location of the default machine?
You can move .docker directory to another drive and create a junction point to it.
Please note that regular shortcut will not work.
For example:
Move .docker directory from C:\Users\username to D:\
and run:
C:\Users\username>mklink /j .docker D:\.docker
Junction created for .docker <<===>> D:\.docker
This is what worked perfectly for me on Windows 7:
Setup the MACHINE_STORAGE_PATH environment variable as the root of the location you want to use for the Docker machines/VMs, cache, etc.
Install Docker Toolbox
Run Docker Quickstart Terminal
Docker Toolbox will now create all the files at the location pointed at by MACHINE_STORAGE_PATH.
UPDATE:
Note that creating a new VM with the new storage path is not ideal, as the Docker Quickstart Terminal scripts don't seem to work with anything not named "default".
If you've already got a VM sitting in the C: drive, then the simplest thing to do would be to go to Oracle VirtualBox and delete the "default" VM, uninstall Docker Toolbox, delete C:\Users\<username>.docker\, and then follow the 3 steps above.
Note: uninstalling and reinstalling Docker Toolbox may not be required. But I haven't tested without it.
Update
To move Docker certificates also, set the DOCKER_CERT_PATH variable to point to the path of the new drive. Thanks to #Nutle for the tip.
Since 2015, there is now (June 2017) Hyper-V, which allows you to define where you want your VHDX files:
See Docker for Windows 1.13.0, 2017-01-19 (stable):
VHDX file containing images and non-host mounted volumes can be moved (using “advanced” tab in the UI)
That will modify the %APPDATA%\Docker\settings.json with a line:
"MobyVhdPathOverride":"C:\\Users\\Public\\Documents\\Hyper-V\\New folder\\MobyLinuxVM.vhdx"
See this thread for more.
Original answer
Currently 2015 , docker-machine forces the use of %USERPROFILE%:
See libmachine/mcnutils/utils.go#L17-L25
As commented in issue 499:
In the meantime, how will users be able to specify where the .docker/machine/* files are stored?
you can by specifying --storage-path on the command line or using the environment variable MACHINE_STORAGE_PATH.
(You can see it implemented in PR 1941)
Joost Den Boer points out in the comments
Just tried '-s <path>' on a Mac and it seems to work fine.
What might not be obvious is that the path option goes before the command.
Running "docker-machine -s /Volumes/other/location' create --driver=virtualbox" created a new VirtualBox image at the other location.
Simply use the VirtualBox graphic interface to relocate the file disk.vmdk:
Copy file C:\Users\{myUsername}\.docker\machine\machines\default\disk.vmdk into another folder, say F:\docker-image\.
Open VirtualBox, select default VM and open Settings.
Open Storage, select current disk.vmdk and release it (or delete it).
Click on Choose Virtual Hard Disk File... and search for copied file in F:\docker-image\
A Warning occurs: VirtualBox complains of old VM UID then go to menu File, select Virtual Media Manager... and release or remove old disk.vmdk
Retry 4., it's done!
If required by your environment then do the relocation also for boot2docker.iso, Snapshot Folder, Video Capture.
Put these two commands when running docker quick start terminal.
I suppose that your new location is "D:\docker" and your new machine name is "docker1"
export MACHINE_STORAGE_PATH=D:\\docker
docker-machine create --driver=virtualbox docker1
This should create a new machine with specified name in your new location.
I could not get the MACHINE_STORAGE_PATH environment variable method working. It kept complaining about missing certificates when first initialising the machine. Still on Windows 7 so have to use docker-toolbox.
I got around the issue by:
Uninstalling Docker Toolbox and restarting machine
Open up Administrator prompt (Find command prompt, hold shift, choose "Run As Administrator")
Deleting .docker from %USERPROFILE%: rmdir /S %USERPROFILE%.docker
Create folder called .docker elsewhere: mkdir a:\.docker
mklink /J %USERPROFILE%.docker a:\.docker
Close Admin command prompt
Reinstall Docker Toolbox
Use the Docker Quickstart Terminal link to bootstrap everything.
Kitematic can be opened now too (though I had to choose the "Use Virtual Box" option on first error.
I have had a bit of trouble with any of the solutions above but this is what worked for me:
define the MACHINE_STORAGE_PATH environment variable to point to your desired
directory/folder.
Install docker-toolbox as normal, if this works for you then fine, but for me it was still installing inside .docker directory.
To fix this I have then stopped and removed the default machine that was created along with .docker folder from the Users directory.
Edited the start.sh script and added the line at the top:
e.g.
export MACHINE_STORAGE_PATH=D:\\Docker
Run the Docker Quickstart Terminal Shortcut, which rebuilt the default machine inside the desired folder
This answer is for people using Docker Toolbox (Windows 10 Home Build 1909, You can follow below steps for docker installation and then location change. I am not adding any images)
Install Docker Toolkit and VM must be installed with Admin Privileges after the installation of docker toolkit (*because Docker Toolkit also installs VM but it's of lower version and creates a problem with other iso files, u can uncheck also, in that case, *). Now we have to change the location of disk.vmdk and update the new location in VM.
Install Docker Toolbox from here. Follow the instructions provided
Now Download Virtual Machine v6+
Install Virtual Machine as Administrator (By Right-clicking and selecting there)
Goto place where your VirtualBox.exe(Not the installer) is present and right-click on it (you can find from the shortcut created on your Desktop)
goto properties --> compatibility --> change setting for all users --> select run this program as administrator
Now close the VM if it's running and run the Kitematic, If it fails (it will probably) then select option provided related to VM (only 2 options are there)
This time it will work, now close it
Changing the Location where Images will be downloaded
open your VM and close a newly running image default (right-click -> close --> power off)
copy paste your disk.vmdk file (for me it's present at C:\Users\Dell\.docker\machine\machines\default\disk.vmdk) to a place where you want to store your images that you download (basically disk.vmdk is what will grow in size when you are using docker)
Now we need to tell the VM also about this change
Right-click default image and goto settings
Select Storage
remove disk.vmdk attachment by right-clicking --> remove (that was the older path binded disk.vmdk)
click on file --> virtual media manager and remove disk.vmdk from here also (Now VM don't know if such a disk.vmdk thing exsists)
Right-click default image --> storage --> add hard disk (this option is just above that iso image)
Now select that disk.vmdk that you have pasted somewhere
Now run your docker cli and then run this command docker run hello-world
If no error is there then it's all done
You can verify size by checking the sizes of those two vmdk disks and then pulling some new images
I have written a very descriptive answer starting from installation because I did face some issues and so wanted to make it highly straight forward for the others.
You can delete your disk.vmdk disk (older one) from your C drive if you want to
Create file called c:\programdata\docker\config\daemon.json with content below where e:\images is location where do you want to store all you images etc. restart docker.
{
"graph": "e:\\images"
}
This Worked like a charm
Reference - https://forums.docker.com/t/where-are-images-stored/9794/11
These answers are out of date, as of the latest release. The location is configurable in the Settings user interface.
https://github.com/docker/for-win/issues/333
I found lots of these answers were out of data, at least they did not work in my environment: win10 PRO, docker desktop community 2.0.0.3. Finally, I resolved this problem by this method:
uninstall docker
open Hyper-V manager (press WIN key and then enter "Hyper")
Change the default virtual hard disk locations in the Hyper-V settings (not on the VM settings) and confirm
install docker
check the disk image location in advanced options of docker settings
I use windows 10 and Docker desktop (community) Version 2.0.0.0, I want to move vhdx file to another Drive.
Right click over Docker Desktop -> Settings
then the Docker Desktop UI will open go to Advance -> Disk image location
just change the path to new destination, the whole process was smooth and fast for me - it's automatically copy the vhdx file from original path to new path restart docker and all work as expected
 
For windows 7:
copy paste your disk.vmdk file (for me it's present at C:\Users\name.docker\machine\machines\default\disk.vmdk) to a place where you want to store your images that you download (basically disk.vmdk is what will grow in size when you are using docker)
in Virtualbox Right-click default image and goto settings
Select Storage remove disk.vmdk attachment by right-clicking --> remove
click on file --> virtual media manager and remove disk.vmdk from here also
Right-click default image --> storage --> add hard disk (this option is just above that iso image)Now select that disk.vmdk that you have pasted somewhere
change now this path in config.json (C:\Users\name.docker\machine\machines\default\config.json)
change the storage path with this new one where u put the location of your hard disk ( "StorePath": "F:\docker-image")
save.

Accessing Docker container files from Windows

How can I access Docker containers Folder and files from Windows file explorer?
If you are running Docker Desktop on Windows, Docker containers don't run natively on the local filesystem, but instead on a hyper-v virtual machine or via WSL2.
Hyper-v (legacy)
In theory, if you were to stop the hyper-v vm, you could open up the vhdx, and if you had the right filesystem drivers, mount it and see the files inside. This is not possible to do while the virtual machine is running. By default the OS that runs for Linux container mode is named "Docker Desktop", but runs busybox.
The file could be found here:
C:\ProgramData\DockerDesktop\vm-data\DockerDesktop.vhdx
WSL2 (modern)
WSL things are slightly different, but not much. You are still effectively working with a virtual environment.
One of the nice advantages of WSL however, is that you can actually browse this file system naively with Windows Explorer.
By browsing to \\wsl$ you will be able to see the file systems of any distributions you have, including docker-desktop.
The docker filesystems on my machine seem to live in:
\\wsl$\docker-desktop-data\version-pack-data\community\docker\overlay2
However, the overlay 'merged' view, which shows the original file system with your changes, doesn't seem to work via windows explorer and gives you a blank window. You can however still see the 'diff' folder, which contains your changes.
You can open a terminal to either of these instances by using the wsl command, from powershell.
Access via Docker
If you wanted to have a look at this Docker OS and filesystem, one way would be to spin up a container, that has access to the OS at the root, something like:
docker run -it --mount type=bind,source=/,target=/host ubuntu /bin/bash
This should drop you into a Ubuntu docker container, with a Bash terminal, which has the root of the hyper-v container (/), mounted on the path '/host'. Looking inside, you will find the Busybox filesystem of the virtual machine that is running docker, and all the containers.
Due to how docker runs, you will be able to access the filesystems of each container. If you are using the overlay2 filesystem for you containers, you would likely find the filesystem layers here for each container:
/host/var/lib/docker/overlay2
If the files you want to browse through in windows explorer, you should be able to configure a samba export of this folder, that is accessible from the host machine, that is accessible while this container is running.
If the goal however is to be able to browse/edit files on the local OS, and have them update inside the container, normally the easiest way to do this, is to mount local directory into the container. This can be done similar to the example above, but you first need to go into the Docker Desktop settings, and enable the mounting of the shared drive into the host virtual machine, and then provide the volume argument when you spin up a container.
If you are using WSL2, there are a few more options available to you, as you can keep your projects inside the WSL layer, while interacting with them from the host OS or via docker. Best practice for this is still in flux, so I'm going to avoid giving direct advice here.
Another related question's reply answers this: https://stackoverflow.com/a/64418064/1115220
\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\
I'll give WordPress app as an example by showing a sample of the docker-compose.yaml file. In order to have project files shown in windows from docker container, you'll need to use ports and volumes
Notice volume and ports.
port 8000 from the local machine maps to 80 within the container.
as for volume, ./ current directory on windows maps to the container image files.
wordpress:
depends_on:
- db
image: wordpress:latest
volumes: ['./:/var/www/html']
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
When running Windows container on Windows Docker Desktop, I was able to see all image files here:
C:\ProgramData\Docker\windowsfilter
(requires admin rights to access, and it would be unwize to delete/modify anything there)
Further, with WizTree tool, it's easy to see real sizes of each image layer and even find which specific files contribute to layer's size.
You should use a mount volume. In your docker run .... command, you may specify a mount volume. The syntax is as follows:
-v /host/directory:/container/directory
An example:
docker run -it -v C:\Users\thomas\Desktop:/root/home --name my_container image1
This would allow the container to write files to /root/home and have them appear on the user thomas' desktop

Resources