How can I copy-paste files into a WSL podman container?

941 Views Asked by At

I spun up a wordpress and mysql container inside podman to test a plugin. I need to copy the wordpress /uploads/ folder inside the new instance. I thought that would be the easiest part, but I soon found out that just copy pasting it wouldn't work - You need permission to perform this action. windows explorer error.

Next I tried using podman cp command. Speciffically:

podman cp :D:/xxx/WP/demo/uploads/ containerID:/var/www/html/wp-content/uploads

but got error rewriting "D:\\xxx\\WP\\demo\\uploads" to be relative to "/": expected root directory to be an absolute path, got "/" error that I didn't figure out how to solve (I tried providing the path in different styles but nothing worked out).

Than I tried to copy it using wsl -d podman-machine-default running:

[user@user /]$ cp -r /mnt/d/xxx/WP/demo/uploads /home/user/.local/share/containers/storage/volumes/wp_test_env_wordpress/_data/wp-content/uploads/

but i got a cannot create directory... permission denied error, even though the exact path already exists.

I tried each of them a bunch of times but still didn't manage to get any to work.

What is the easiest way I could copy over a file from Windows FS into a podman container?

1

There are 1 best solutions below

0
Janez Kranjski On

The only solution I found to work was to cd directly into [user@user wp-content]$(wsl -d podman-machine-default) and to run sudo cp -r /mnt/d/xxx/WP/demo/uploads/ ./.

I am still not sure why using the whole path didn't work and would love to know if an easier solution exists (enabling copy and paste directly between windows and WSL maybe).