2014-01-26 27 views
0

我是Docker.io的新手。我在aws實例中使用標準映像ubuntu從index.docoker.io成功創建了映像。我在映像中安裝了node.js和簡單的web應用程序,並創建了docker容器併成功通過以下方式進行測試: curl -i localhost:49160 in瀏覽器我指定hostip:1704,但我沒有得到頁面無法瀏覽運行碼頭集裝箱的nodejs web應用程序

+0

你可以發佈你的Dockerfile和命令你運行容器嗎? –

+0

FROM ubuntu:latest MAINTAINER s rambabu RUN apt-get install -y python-software-properties python RUN add-apt-repository ppa:chris-lea/node.js RUN echo「deb http:// us。 archive.ubuntu.com/ubuntu/ precise universe「>> /etc/apt/sources.list RUN apt-get update RUN apt-get install -y nodejs #RUN apt-get install -y npm ADD/src/src RUN cd src; npm install EXPOSE 1704 CMD [「node」,「/src/index.js」] – user3237421

+0

我使用的運行命令是:sudo docker run -p 49160:1704 -d ssit/ssit-node-hello:latest – user3237421

回答

1

它看起來像你使用錯誤的端口來訪問應用程序。嘗試將瀏覽器指向http://<host_ip>:49160

容器內的應用程序暴露了端口1704,並且當您使用參數-p 49160:1704運行容器時,您將主機上的端口49160轉發到容器內的端口1704 。使用瀏覽器訪問應用程序時,使用主機的IP和打開的端口(在本例中爲49160)。

有關更多信息,請參閱Redirect ports文檔。

+0

你是對的。非常感謝你 – user3237421