DEV Community

loading...

Discussion on: docker-compose up your entire Laravel + Apache + MySQL development environment.

veevidify profile image
V Author • Edited

There is a neat little trick to run a docker container as if it's a binary in your host. This is very useful for things like composer or npm which only modifies files statically. Example:

$ cd /your/project/folder
$ docker run -it -u 1000:1000 -v "$PWD":/usr/src/app -w /usr/src/app --rm node:10 npm install

Make sure all the parameters are what you need, e.g. uid, node version, etc.

Even though I copy composer binary into the my own app image for "encapsulation", if we intend to only ever use such binary for static files modification on the host, that wouldn't be necessary. Instead this trick makes it more clean once you start having 5 6 container runtime for these sorts of purposes.

I conveniently "missed out" this part due to how varied people's use cases with node are.