turnbullpress / dockerbook-code

The code and configuration examples from The Docker Book (http://www.dockerbook.com)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nodejs container fails based on nodejs image

brunojppb opened this issue · comments

Book version: v18.03.1-ce

When generating the nodejs image on Chapter 6: Building services with Docker, based on the book snippet, the nodejs version installed is 4.
the express app don't run on it.

Current book snippet

FROM ubuntu:16.04
LABEL maintainer="james@example.com"
ENV REFRESHED_AT 2016-06-01
RUN apt-get -yqq update
RUN apt-get -yqq install nodejs npm
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN mkdir -p /var/log/nodeapp
ADD nodeapp /opt/nodeapp/
WORKDIR /opt/nodeapp
RUN npm install
VOLUME [ "/var/log/nodeapp" ]
EXPOSE 3000
ENTRYPOINT [ "nodejs", "server.js" ]

To run the app container, I had to update node version to 10

My Dockerfile update

FROM ubuntu:16.04
LABEL maintainer="bruno@example.com"
ENV REFRESHED_AT 2018-12-02

RUN apt-get -yqq update
RUN apt-get -yqq install curl build-essential
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash
# nodejs package already includes npm
RUN apt-get install -y nodejs

# check node version
RUN echo $(nodejs -v)
# Create logs folder
RUN mkdir -p /var/log/nodeapp
# Add our local nodeapp folder to opt
ADD nodeapp /opt/nodeapp/
# use opt path as our working directory
WORKDIR /opt/nodeapp/
# install app dependencies
RUN npm install
# map the logs folder to a persistent volume in the host machine
VOLUME [ "/var/log/nodeapp" ]
# expose express app port
EXPOSE 3000
# fire-up node app
ENTRYPOINT [ "nodejs", "server.js" ]

Thanks! This is already fixed in the current code.