【发布时间】:2019-09-15 19:12:45
【问题描述】:
我正在尝试在 docker 中运行 Apache Airflow,尽管网络服务器似乎已正确打开,但我可以从本地主机访问网络服务器。
Docker-compose
version: '3'
services:
webserver:
build: .
container_name: data-webserver
depends_on:
- postgres
volumes:
- ./src:/src
ports:
- "8080:8080"
postgres:
image: postgres:latest
container_name: data-postgres
environment:
- POSTGRES_USER=airflow
- POSTGRES_PASSWORD=airflow
- POSTGRES_DB=airflow
ports:
- "5432:5432"
Dockerfile
FROM ubuntu
ENV PYTHONUNBUFFERED 1
ADD . .
ADD ./docker_src/my_folder /etc
ENV PYTHONPATH "${PYTONPATH}:/maintenance:/database_utils:/utils"
RUN apt-get update && apt-get install -y python-pip mysql-server
RUN pip install -r docker_src/requirements.pip
CMD tail -f /dev/null
气流初始化:
airflow initdb
Airflow 网络服务器:
airflow webserver -p 8080
Airflow 网络服务器响应:
2019-04-26 08:10:13 +0000] [31] [INFO] Starting gunicorn 19.9.0
[2019-04-26 08:10:13 +0000] [31] [INFO] Listening at: http://0.0.0.0:8080 (31)
[2019-04-26 08:10:13 +0000] [31] [INFO] Using worker: sync
[2019-04-26 08:10:13 +0000] [36] [INFO] Booting worker with pid: 36
[2019-04-26 08:10:13,684] {__init__.py:51} INFO - Using executor SequentialExecutor
[2019-04-26 08:10:13 +0000] [37] [INFO] Booting worker with pid: 37
[2019-04-26 08:10:13,746] {__init__.py:51} INFO - Using executor SequentialExecutor
[2019-04-26 08:10:13 +0000] [41] [INFO] Booting worker with pid: 41
[2019-04-26 08:10:13 +0000] [42] [INFO] Booting worker with pid: 42
[2019-04-26 08:10:13,850] {__init__.py:51} INFO - Using executor SequentialExecutor
[2019-04-26 08:10:13,866] {__init__.py:51} INFO - Using executor SequentialExecutor
[2019-04-26 08:10:13,974] {__init__.py:305} INFO - Filling up the DagBag from /root/airflow/dags
[2019-04-26 08:10:14,058] {__init__.py:305} INFO - Filling up the DagBag from /root/airflow/dags
[2019-04-26 08:10:14,156] {__init__.py:305} INFO - Filling up the DagBag from /root/airflow/dags
[2019-04-26 08:10:14,164] {__init__.py:305} INFO - Filling up the DagBag from /root/airflow/dags
[2019-04-26 08:10:34 +0000] [31] [INFO] Handling signal: winch
[2019-04-26 08:10:35 +0000] [31] [INFO] Handling signal: winch
[2019-04-26 08:10:44 +0000] [31] [INFO] Handling signal: ttin
[2019-04-26 08:10:44 +0000] [56] [INFO] Booting worker with pid: 56
[2019-04-26 08:10:44,937] {__init__.py:51} INFO - Using executor SequentialExecutor
[2019-04-26 08:10:45,143] {__init__.py:305} INFO - Filling up the DagBag from /root/airflow/dags
[2019-04-26 08:10:45 +0000] [31] [INFO] Handling signal: ttou
[2019-04-26 08:10:45 +0000] [36] [INFO] Worker exiting (pid: 36)
[2019-04-26 08:11:16 +0000] [31] [INFO] Handling signal: ttin
[2019-04-26 08:11:16 +0000] [61] [INFO] Booting worker with pid: 61
[2019-04-26 08:11:16,198] {__init__.py:51} INFO - Using executor SequentialExecutor
[2019-04-26 08:11:16,441] {__init__.py:305} INFO - Filling up the DagBag from /root/airflow/dags
[2019-04-26 08:11:17 +0000] [31] [INFO] Handling signal: ttou
[2019-04-26 08:11:17 +0000] [37] [INFO] Worker exiting (pid: 37)
[2019-04-26 08:11:47 +0000] [31] [INFO] Handling signal: ttin
[2019-04-26 08:11:47 +0000] [66] [INFO] Booting worker with pid: 66
[2019-04-26 08:11:47,453] {__init__.py:51} INFO - Using executor SequentialExecutor
[2019-04-26 08:11:47,670] {__init__.py:305} INFO - Filling up the DagBag from /root/airflow/dags
[2019-04-26 08:11:48 +0000] [31] [INFO] Handling signal: ttou
[2019-04-26 08:11:48 +0000] [41] [INFO] Worker exiting (pid: 41)
当我从我的电脑上运行时:http://localhost:8080/
尽管我在 docker-compose 中公开了端口,但我无法访问该网站。
问题出在哪里?
停靠 ps 输出
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9aa56948cdf6 analytics-etl_webserver "/bin/sh -c 'tail -f…" 4 minutes ago Up 4 minutes 0.0.0.0:8080->8080/tcp data-webserver
20db5fd63ad8 postgres:latest "docker-entrypoint.s…" 4 hours ago Up 33 minutes 0.0.0.0:5432->5432/tcp data-postgres
【问题讨论】:
-
如何检查
docker ps的输出,如果它正在运行,它应该显示在哪个 ip 和端口上运行。 -
@Biranjan 刚刚添加
-
我也有同样的问题。你找到解决办法了吗?
-
@JavierLópezTomás 不,抱歉。仍然停止了这个问题。