2017-06-06 9 views
1

を実行すると、私のDockerfileです:ERR_EMPTY_RESPONSEここドッカー

# CentOs base image 
FROM centos:centos6.8 

# install python, pip, apache and other packages 
RUN yum -y update; yum clean all 
RUN yum -y install epel-release; yum clean all 
RUN yum -y install centos-release-scl; yum clean all 
RUN yum -y install python27; yum clean all 
RUN yum -y install python-devel.x86_64; yum clean all 
RUN yum -y install python-pip; yum clean all 
RUN yum -y install gcc; yum clean all 
RUN yum -y install httpd httpd-devel mod_ssl; yum clean all 

# Make a non root user so I can run mod_wsgi without root 
# USER adm 

# install Python modules needed by the Python app 
COPY requirements.txt /usr/src/app/ 
RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt 

# copy files required for the app to run 
COPY . /usr/src/app/ 

# tell the port number the container should expose 
EXPOSE 80 

# run the application 
# CMD ["mod_wsgi", "start-server run_apache_server.wsgi"] 
# CMD ["cat", "/etc/passwd"] 
# CMD ["cat", "/etc/group"] 
# CMD ["find", "/"] 
CMD ["/bin/sh", "-c", "/usr/bin/mod_wsgi-express start-server run_apache_server.wsgi --user adm --group apache"] 

私はアプリを実行することができます:

$ docker run -d -P --name myapp jacobirr/pleromatest 

をし、TCPポート80を参照してください。

$ docker port myapp 
80/tcp -> 0.0.0.0:32769 

は、ここに私の要件です。 txt:

Flask==0.10.1 
Flask-Restless==0.13.1 
Flask-SQLAlchemy==0.16 
Jinja2==2.7 
MarkupSafe==0.18 
SQLAlchemy==0.8.2 
Werkzeug==0.9.2 
gunicorn==17.5 
itsdangerous==0.22 
mimerender==0.5.4 
python-dateutil==2.1 
python-mimeparse==0.1.4 
requests==1.2.3 
six==1.3.0 
wsgiref==0.1.2 
setuptools==5.4.2 
mod_wsgi==4.5.15 

ブラウザでlocalhost:32769にアクセスできないのはなぜですか?私はこれが以下に関係していると思われます:

•Apache/Apacheを実行しているユーザー/グループ?

•私はmod_wsgiをインストールしていますが、それはドッカーの "ファイルシステム"にはありませんので、mod_wsgi-expressを使用する必要がありますか?

更新:

'1' Netstatのは示しています

[[email protected] app]# netstat -l 
Active Internet connections (only servers) 
Proto Recv-Q Send-Q Local Address    Foreign Address    State  
tcp  0  0 *:irdmi      *:*       LISTEN  
Active UNIX domain sockets (only servers) 
Proto RefCnt Flags  Type  State   I-Node Path 
unix 2  [ ACC ]  STREAM  LISTENING  113181 /tmp/mod_wsgi-localhost:8000:0/wsgi.1.0.1.sock 

'2' のhttpd私のコンテナで実行されているように見える:

[[email protected] mod_wsgi-localhost:8000:0]# ps aux | grep httpd 
root   1 0.0 0.2 64060 5084 ?  Ss 21:17 0:00 httpd (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND 
adm   6 0.0 0.6 350928 13936 ?  Sl 21:17 0:00 (wsgi:localhost:8000:0) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND 
adm   7 0.0 0.1 64192 3248 ?  S 21:17 0:00 httpd (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND 
+0

EMPTRY_RESPONSEは、ドッキング用のコンテナへのTCP接続しかし、サーバー側は何も返さずに接続を閉じました。たぶん、ドッカーホストの内部の 'httpd'アプリケーションログをチェックして、何が起こったのか、そして接続がここで行われたのかどうか確認してください。 –

+1

'var/log/httpd'は空です。私はすべてのコンテナの内部をログで調べましたが、そこには表示されません。httpdのために、私はこのファイルに気付いた: './tmp/mod_wsgi-localhost:8000:0/httpd.conf'これはポート8000​​が使用中であることを暗示しているようだ...それが問題の一部であるかどうかは分からない。 – JacobIRR

+0

ドッカーイメージで 'netstat -l'を実行すると、ポート80は開いていますか? httpdは動作していますか? –

答えて

1

すべての出力から、httpd/uwsgiプロセスは確実に8000にバインドされており、これはコンテナに公開する必要があるポートです。

この行のnetstatは、8000にバインドを表示していますが、それ以外は表示されません。

tcp  0  0 *:irdmi      *:*       LISTEN  

ここは明らかにされていませんが、あなたは--numeric-ports引数を使用している場合、それはそのknown portに8000を変換しません。お使いのドッキングウィンドウのファイルで

、あなたのコンテナを起動すると、再びあなたが

EXPOSE 8000 

、あなたはまた、ホストマシン上で使用するポートを指定することができますする必要があります。この後

docker run -p 8080:8000 --name ... 

を、あなたがする必要がありますブラウザを使用してヒットすることができます

localhost:8080 -> container:8000 
+0

これはすべて意味があります。素晴らしい、すみません! – JacobIRR

1

あなたDockerfileにこれを追加し、直前CMD:

WORKDIR /usr/src/app/ 

あなたのstart-apache-serverファイルがそのディレクトリにあると仮定します。これは、wsgiが必要なファイルを見つけるのに役立ちます。

関連する問題