2017-01-09 67 views
0

我正在Docker容器中運行一個節點應用程序。同一端口上的2個進程?

這裏是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 

當我ssh到容器中,我看到了兩個prcesses不同的PID runnng這個容器

[email protected]:/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 

上這是預期的嗎?

回答

1

這並不意味着它們都在8000上進行監聽。這意味着它們具有在8000上進行監聽的參數。在這種情況下,有一個包裝器sh -c http-server ...,它調用node /usr/src

您應該使用命令lsofnetstat來查看實際打開的內容或檢入/ proc。

相關問題