2016-07-23 21 views
-1

ドッカーコンテナを使用してWebアプリケーションをテストしようとしていますが、ブラウザからアクセスしようとすると表示されません。Dockerコンテナを使用してWebアプリケーションが表示されない

version: '2' 
services: 
db: 
    image: postgres 
    volumes: 
     - ~/pgdata:/var/lib/postgresql/data/pgdata 
    environment: 
     POSTGRES_PASSWORD: "dbpassword" 
     PGDATA: "/var/lib/postgresql/data/pgdata" 
    ports: 
     - "5432:5432" 
web: 
    build: 
     context: . 
     dockerfile: Dockerfile-web 
    ports: 
     - "5000:5000" 
    volumes: 
     - ./web:/web 
    depends_on: 
     - db 
backend: 
    build: 
     context: . 
     dockerfile: Dockerfile-backend 
    volumes: 
     - ./backend:/backend 
    depends_on: 
     - db 

dockerfile-ウェブは

FROM python 
ADD web/requirements.txt /web/requirements.txt 
ADD web/bower.json /web/bower.json 
WORKDIR /web 

RUN \ 
    wget https://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-x64.tar.xz && \ 
    tar xJf node-*.tar.xz -C /usr/local --strip-components=1 && \ 
    rm -f node-*.tar.xz 

RUN npm install -g bower 
RUN bower install --allow-root 

RUN pip install -r requirements.txt 
RUN export MYFLASKAPP_SECRET='makethewebsite' 

CMD python manage.py server 

私のドッキングウィンドウのマシンのIPが

ドッカ・マシンのIP 192.168.99.100

であるように見えるように

ドッキングウィンドウのコンファイルが見えます

でも試したときに http://192.168.99.100:5000/ 私のブラウザには、サイトには到達できないとしか書かれていません。 接続を拒否しているようです。私は、ブラウザで私のデータベースにpingを実行すると

私は、ログ http://192.168.99.100:5432/

の私のデータベースの応答はだから私は

$ docker exec 3bb5246a0623 wget http://localhost:5000/ 
--2016-07-23 05:25:16-- http://localhost:5000/ 
Resolving localhost (localhost)... ::1, 127.0.0.1 
Connecting to localhost (localhost)|::1|:5000... failed: Connection refused. 
Connecting to localhost (localhost)|127.0.0.1|:5000... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 34771 (34K) [text/html] 
Saving to: ‘index.html.1’ 

0K .......... .......... .......... ...     100% 5.37M=0.006s 

2016-07-23 05:25:16 (5.37 MB/s) - ‘index.html.1’ saved [34771/34771] 

誰もが私が得ることができる方法を知っているコンテナ内のwgetを試してみましたが、得たことを見ることができます私のウェブアプリケーションは私のブラウザを通して表示されますか?

答えて

0

私のフラスコのアプリケーションでは、外部の可視性を有効にする必要がありました。 あなたはそれをここに見ることができます Can't connect to Flask web service, connection refused

+0

あなたはそのリンクの内容の要約を提供できますか?他のユーザーにとっては非常に便利です。 – SilentMonk