If you use a production docker image for your local dev environment it’s very likely one of the builds stages is running a command which installs your dependencies such as npm install, composer install or go get.
Now you don’t want to adjust your production docker image but at the same time, your dependency installs can take a long time and you really don’t want to run the command twice.
An easy solution would be to tell docker to not mount the directory into the container with the rest of your project code but then you don’t get all the useful information provided by your IDE.
Enter docker cp and volume overrides.
Using docker cp and overriding the volume we wish to copy from the container allows us to pull directories such as node_modules out of the built docker image. This is great because it means we don’t need to run our installs twice. It also has the added benefit of reflecting your production environment files better and eliminates the issue of slightly different language versions and in turn, dif