首页 > 解决方案 > 将 Redash 集成到 Docker 容器中

问题描述

问题

  1. 在我的 Docker 中安装 Redash
  2. 在 Docker 中运行的我的应用程序中提供 Redash 图表

测试容器基本上消除了仅运行 Flask 应用程序进行演示的问题中的任何第 3 方因素。

应用程序.py

from flask import Flask
import os
import socket

app = Flask(__name__)

@app.route("/")
def hello():
    html = "<h3>Hello World!</h3>"
    return html

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=80)

Dockerfile

# Use an official Python runtime as a parent image
FROM python:2.7-slim

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Run app.py when the container launches
CMD ["python", "app.py"]

docker-compose-yaml

version: '3' 
services: 
    redash: 
        image: redash/redash 
        ports: 
            - "5001:5000" 
    test: 
        build: .
        ports: 
            - "80:80"

完整的日志:

$ docker-compose up
Starting test1_redash_1 ... done
Recreating test1_test_1 ... done
Attaching to test1_redash_1, test1_test_1
test1_redash_1 exited with code 0
test_1    |  * Serving Flask app "app" (lazy loading)
test_1    |  * Environment: production
test_1    |    WARNING: Do not use the development server in a production environment.
test_1    |    Use a production WSGI server instead.
test_1    |  * Debug mode: off
test_1    |  * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
test_1    | 192.168.0.1 - - [13/Jul/2018 03:53:08] "GET / HTTP/1.1" 200 -

redash的Dockerhub链接https://hub.docker.com/r/redash/redash/


我究竟做错了什么?

标签: dockerdocker-composeredash

解决方案


推荐阅读