Touch up Node.js and MongoDB examples

- Remove extraneous '-' in sudo note.
- Correct space formatting (minor).
- Simplify instructions for install EPEL and install with yum directly.
- Add `nodejs` to yum install list explicitly to match the comments -- more transparent for new users who might not be clear `npm` package also installs `nodejs`.
- Remove '--noprealloc` from MongoDB example as the option has been depcated since Mongo 2.6 and is now the default behaviour. See: http://docs.mongodb.org/manual/reference/program/mongod/

Signed-off-by: Charles Chan <charleswhchan@users.noreply.github.com>
This commit is contained in:
Charles Chan
2015-09-06 14:34:54 -07:00
parent 7ce97dbe30
commit 549c8ea96e
6 changed files with 27 additions and 36 deletions
+12 -15
View File
@@ -10,14 +10,11 @@ parent = "smn_applied"
# Dockerizing a Node.js web app
> **Note**:
> - **If you don't like sudo** then see [*Giving non-root
> access*](/installation/binaries/#giving-non-root-access)
> **Note**: **If you don't like sudo** then see [*Giving non-root
> access*](/installation/binaries/#giving-non-root-access)
The goal of this example is to show you how you can build your own
Docker images from a parent image using a `Dockerfile`
. We will do that by making a simple Node.js hello world web
application running on CentOS. You can get the full source code at
In this example, we are going to learn how to build a Docker image to run a
simple Node.js "hello world" web application on CentOS. You can get the full source code at
[https://github.com/enokd/docker-node-hello/](https://github.com/enokd/docker-node-hello/).
## Create Node.js app
@@ -75,16 +72,16 @@ available on the [Docker Hub](https://hub.docker.com/):
Since we're building a Node.js app, you'll have to install Node.js as
well as npm on your CentOS image. Node.js is required to run your app
and npm to install your app's dependencies defined in
and npm is required to install your app's dependencies defined in
`package.json`. To install the right package for
CentOS, we'll use the instructions from the [Node.js wiki](
https://github.com/joyent/node/wiki/Installing-Node.js-
via-package-manager#rhelcentosscientific-linux-6):
# Enable EPEL for Node.js
RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# Enable Extra Packages for Enterprise Linux (EPEL) for CentOS
RUN yum install -y epel-release
# Install Node.js and npm
RUN yum install -y npm
RUN yum install -y nodejs npm
To bundle your app's source code inside the Docker image, use the `COPY`
instruction:
@@ -97,7 +94,7 @@ Install your app dependencies using the `npm` binary:
# Install app dependencies
RUN cd /src; npm install
Your app binds to port `8080` so you'll use the` EXPOSE` instruction to have
Your app binds to port `8080` so you'll use the `EXPOSE` instruction to have
it mapped by the `docker` daemon:
EXPOSE 8080
@@ -112,10 +109,10 @@ Your `Dockerfile` should now look like this:
FROM centos:centos6
# Enable EPEL for Node.js
RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# Enable Extra Packages for Enterprise Linux (EPEL) for CentOS
RUN yum install -y epel-release
# Install Node.js and npm
RUN yum install -y npm
RUN yum install -y nodejs npm
# Bundle app source
COPY . /src