I never see foo.php in my directory named code. How can I see foo.php?
what is the logic of it? When I remove the ‘volumes’ parameter, it creates in the container, but my code directory does not see.Because it is not synchronous.
There must be hundreds of examples on the web for using docker in development context. Either the one you follow is wrong so find a better one, or follow it more closley.
Here’s the first thing: mounting a volume hides the content built into the image. Foo.php inside the image is hidden by mounting ./code on top of foo.php’s directory.
Second thing, in development context, the files you intend to edit should be on the host filesystem, not inside the image. Otherwise, the changes would be gone when the container is removed. (Or, the changes would be more difficult to get to, even if you could save them in docker storage before the container is removed.)
So, remove the touch command from the dockerfile and rebuild the image. It’s obfuscating.
Then touch or add content to ./code/foo.php.
Then start the container again.