# Native Node Modules

**URL:** <https://forums.docker.com/t/native-node-modules/38361>\
**Category:** General\
**Created:** [September 18, 2017, 10:47pm UTC](https://forums.docker.com/t/native-node-modules/38361 "2017-09-18T22:47:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danthedocker](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@danthedocker](https://forums.docker.com/u/danthedocker)\
**Post date:** [September 18, 2017, 10:47pm UTC](https://forums.docker.com/t/native-node-modules/38361/1 "2017-09-18T22:47:32Z")

</div>

Hi,

Very new to Docker so please excuse what is likely a basic question. I am trying to understand at which point the node modules are installed if I have a run npm install command in my Dockerfile such as:

```
FROM node:8.4.0

# Create our app directory.
RUN mkdir -p /usr/app
WORKDIR /usr/app

# Install dependancies.
COPY package.json /usr/app/
RUN npm install

COPY . /usr/app

# Start the app.
CMD ["npm", "start"]

EXPOSE 80

```

Is this at the time the image is built? If so how are native node modules handled (e.g. bcrypt) if I run this image as a container on a different machine e.g. build the image on a Mac and then run a container on an EC2 instance?

I feel I have probably missed a very simple concept so any help would be greatly appreciated!

Thanks  
Dan 🙂

---

<div class="post-metadata">

**Author:** ![dmaze](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@dmaze](https://forums.docker.com/u/dmaze)\
**Post date:** [September 19, 2017, 12:14am UTC](https://forums.docker.com/t/native-node-modules/38361/2 "2017-09-19T00:14:10Z")

</div>

> [@danthedocker](#):
>
> I am trying to understand at which point the node modules are installed if I have a run npm install command in my Dockerfile […] Is this at the time the image is built?

Yes, and more specifically when the `RUN npm install` command executes.

> [@](#):
>
> If so how are native node modules handled (e.g. bcrypt) if I run this image as a container on a different machine e.g. build the image on a Mac and then run a container on an EC2 instance?

If you’re running Docker on a Mac, there is an intermediate Linux virtual machine that you may or may not see, but it is always a Linux image. The userspace is also fixed (it’s whatever Linux distribution the `node:8.4.0` base image starts from).

If you `docker push` the image to a registry, then it pushes the binary contents of the image, and so when you `docker pull` or `docker run` the image on an EC2 instance, it pulls that same binary back down. If you’re repeating the `docker build` from source on the target machine, then it will repeat the same installation steps (on the same base operating system and the same base userspace) and it should get out a near-identical installation.

---

<div class="post-metadata">

**Author:** ![danthedocker](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@danthedocker](https://forums.docker.com/u/danthedocker)\
**Post date:** [September 19, 2017, 12:30am UTC](https://forums.docker.com/t/native-node-modules/38361/3 "2017-09-19T00:30:53Z")

</div>

Brilliant! Thanks, I’ve been trying to cram too many concepts into my head too quickly and your simple description just gave me my light bulb moment!! 😃
