Files haven't been copied to volume folder during docker run

Ah, you’re running into some WordPress copy-on-first-run functionality, not some Docker functionality. I indeed see the following:

% docker run --rm -v ~/somedir:/var/www/html wordpress
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html

Note, however, how that says “WordPress not found in…”. That’s not something Docker does, but something the WordPress image is doing for you. And it’s then probably not taking the container’s /var/www/html as the source folder (which WordPress cannot even access access anymore, see the “If you mount a bind mount or non-empty volume into a directory in the container in which some files or directories exist, these files or directories are obscured by the mount” quote from the documentation in my first answer). And that source folder it uses is not the folder to which you added files using COPY.

For any other folder, like docker run --rm -v ~/somedir:/etc/apache2/conf-available wordpress this shows the same message from WordPress, but also you won’t see anything in your local folder, for bind mounts. (Docker only does the copy on first run for empty volumes, not for empty bind mounts.)

1 Like