2016-06-07 220 views
1

使用下面的dockerfile創建帶有centos7的新docker映像(rm/node:10.0)。映射docker端口失敗

FROM rm/node:9.0 
EXPOSE 3000 

WORKDIR /Reader_Manager/SISPlatform/Auth 
RUN npm install 

WORKDIR /Reader_Manager/SISPlatform/Auth/portal 
CMD npm run-script dev-server-linux 

「NPM運行腳本DEV-服務器LINUX」將調用在其下面的package.json文件

"dev-server-linux": "export NODE_ENV=development && pm2 start --no-daemon AuthServer -o ../../logs/pm2/out/auth_out.log -e ../../logs/pm2/err/auth_error.log --log-date-format 'DD-MM-YYYY HH:mm:ss.SSS'", 

限定,當我試圖在後臺運行它正在運行時創建搬運工圖像命令。

docker run -d rm/node:10.0 
08633576828fe33ba880c7b6a40dd9306c885d24ce36a765a459f5acc8e91808 
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning. 


docker ps 
CONTAINER ID  IMAGE    COMMAND     CREATED    STATUS    PORTS    NAMES 
08633576828f  rm/node:10.0  "/bin/sh -c 'npm run-" About a minute ago Up About a minute 3000/tcp   nostalgic_gates 

因爲我在容器中運行nodejs,暴露了3000端口。所以我試圖映射3000端口,但它是失敗的錯誤。

[[email protected] docker_test]$ docker run -p 3000:3000 -d rm/node:10.0 
3160c27cd2ee964474d137024c1f392dafe5242874842b5f5cdf28a4dfb27e51 
Error response from daemon: Cannot start container 3160c27cd2ee964474d137024c1f392dafe5242874842b5f5cdf28a4dfb27e51: failed to create endpoint big_wing on network bridge: COMMAND_FAILED: '/sbin/iptables -w2 -t nat -A DOCKER -p tcp -d 0/0 --dport 3000 -j DNAT --to-destination 172.17.0.3:3000 ! -i docker0' failed: iptables: No chain/target/match by that name. 

回答

0

你的系統上的東西已經刪除了它需要工作的docker iptables條目。兩個定位已經提出here

爲CentOS:

sudo service docker restart 
sudo service iptables save 

而對於Ubuntu的:

sudo apt-get install iptables-persistent 
sudo service docker restart 
iptables-save > /etc/iptables/rules.v4 # you may need to "sudo -s" to get a root shell first 

泊塢窗重啓後,你應該看到nat表下的泊塢窗鏈:

iptables -t nat -vL