Tag: dockerfile

How to cache the RUN npm install instruction when docker build a Dockerfile

I am currently developing a Node backend for my application. When dockerizing it (docker build .) the longest phase is the RUN npm install. The RUN npm install instruction runes on every small server code change, impacting the productivity by making the developer wait for the build to finish each time. I found that running […]

Add a volume to Docker, but exclude a sub-folder

Supposed I have a Docker container and a folder on my host /hostFolder. Now if I want to add this folder to the Docker container as a volume, then I can do this either by using ADD in the Dockerfile or mounting it as a volume. So far, so good. Now /hostFolder contains a sub-folder, […]

What’s the difference between RUN and CMD in a docker file and when should I use one or the other?

I’m confused about when should I use CMD vs RUN. For example, to execute bash/shell commands (i.e. ls -la) I would always use CMD or is there a situation where I would use RUN? Trying to understand the best practices about these two similar Dockerfile directives.

Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.