0

Thanks to Docker for Mac, it's now possible to run a local development server inside a Docker container. We simply run the container with the local repository mounted as a volume. If we make a change locally, it's automatically updated on the container (thanks to the volume) and we don't have to restart the server.

What we can't figure out is how these images should be built for production. Take this simple Node service as an example:

FROM node:6

# Install the dependencies outside of the application's volume directory
ADD package.json .npmrc /node/
RUN npm install --prefix /node

# Set up the correct paths for the new node modules installation
ENV NODE_PATH /node/node_modules:$NODE_PATH
ENV PATH $PATH:/node/node_modules/.bin

# Create an endpoint to mount the service's repository
VOLUME /runtime
WORKDIR /runtime

# Expose the application's port
EXPOSE 10010

# Start the server
CMD scripts/start

In order to create our production container, we'd really like to ADD the files instead of mounting a volume. That way we can deploy the image and simply run it. What's the correct way to handle this with Docker?

LandonSchropp
  • 10,084
  • 22
  • 86
  • 149
  • Possible duplicate of [How do I build docker images when my development environment mounts my codebase into the container?](http://stackoverflow.com/questions/40914696/how-do-i-build-docker-images-when-my-development-environment-mounts-my-codebase) – Matt Dec 07 '16 at 04:07

1 Answers1

1

Have a NFS in PROD and create a mount point. Use that mount point while starting the container via -v Option. So that it can be shared across multiple containers and handle the load balancing stuff. When their is a stale mount created, that time only you need to restart the container / create new container.

Senthil
  • 2,156
  • 1
  • 14
  • 19