0

I am running a node app inside a docker container.

Here is the dockerfile

FROM maven:3.3.3-jdk-8

#install node
RUN apt-get update
RUN apt-get -qq update
RUN apt-get install -y nodejs npm

# TODO could uninstall some build dependencies
RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

# Install packages for envsubst
RUN apt-get update && apt-get upgrade -y --force-yes && rm -rf /var/lib/apt/lists/*;
RUN apt-get update
RUN apt-get install -y gettext-base


# Create app directory 
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# cache package.json and node_modules to speed up builds
COPY src src
COPY package.json package.json
#COPY node_modules node_modules
COPY pom.xml pom.xml
COPY Gruntfile.js Gruntfile.js
COPY gulpfile.js gulpfile.js
COPY settings.xml settings.xml

# Substitute dependencies from environment variables
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

EXPOSE 8000

entrypoint.sh

#!/bin/sh

rm -rf /usr/src/app/src/js/app.js
envsubst < "/usr/src/app/src/js/envapp.js" > "/usr/src/app/src/js/app.js"
mvn clean  install -DskipTests -s settings.xml 
exec npm start

When I ssh into the container , I see two prcesses with different PIDs runnng on this container

root@63387c253612:/usr/src/app# ps aux | grep '8000'
root       158  0.0  0.0   4332   648 ?        S    13:54   0:00 sh -c http-server -a 0.0.0.0 -p 8000
root       159  0.1  0.7 668520 15260 ?        Sl   13:54   0:00 node /usr/src/app/node_modules/.bin/http-server -a 0.0.0.0 -p 8000
root       168  0.0  0.0  12808   976 ?        S+   13:55   0:00 grep 8000

Is this expected?

user_mda
  • 18,148
  • 27
  • 82
  • 145

1 Answers1

1

That doesn't mean that they are both listening on 8000. That means they have parameters to listen on 8000. In this case, there is a wrapper sh -c http-server ... that is calling node /usr/src.

You should use the commands lsof or netstat to see what is actually open, or check in /proc.

Nick Burke
  • 949
  • 9
  • 10