我正在尝试在docker中运行Apache Airflow,尽管似乎已正确打开Web服务器,但仍可以从本地主机访问Web服务器。
Docker-compose
Sort sort = Sort.by(new Sort.Order(Sort.Direction.DESC, "created_time"));
Pageable pageable = PageRequest.of(page, size, sort);
Page<Model> page = repository.findAll(pageable);
Dockerfile
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"
气流初始化:
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 webserver -p 8080
从计算机上运行时: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)
尽管我在docker-compose中公开了端口,但仍无法访问网站。
问题出在哪里?
Docke ps输出
http://localhost:8080/
答案 0 :(得分:0)
查看您的compose file
,我们可以看到您尚未将webserver's
容器端口(8080)
映射到主机。
您的docker-compose.yml
应该如下所示:
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"