Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

IBM Cloud Functions: How to run a Docker function?

FROM python:3.7
COPY ./src /data/python
WORKDIR /data/python
RUN pip install --no-cache-dir flask
EXPOSE 8080
CMD ["python", "main.py"]
  • main.py
import os
from flask import Flask
app = Flask(__name__)

@app.route('/')
def index():
    return {'body': os.environ.items()}


def run():
    app.run(host='0.0.0.0', port=8080)


if __name__ == '__main__':
    run()

click invoke result

[
  "2021-01-29T09:53:30.727847Z    stdout: * Serving Flask app "main" (lazy loading)",
  "2021-01-29T09:53:30.727905Z    stdout: * Environment: production",
  "2021-01-29T09:53:30.727913Z    stdout: WARNING: This is a development server. Do not use it in a production deployment.",
  "2021-01-29T09:53:30.727918Z    stdout: Use a production WSGI server instead.",
  "2021-01-29T09:53:30.727923Z    stdout: * Debug mode: off",
  "2021-01-29T09:53:30.731130Z    stderr: * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)",
  "2021-01-29T09:53:30.747035Z    stderr: 172.30.139.167 - - [29/Jan/2021 09:53:30] "u001b[33mPOST /init HTTP/1.1u001b[0m" 404 -",
  "2021-01-29T09:53:30.748Z       stderr: The action did not initialize or run as expected. Log data might be missing."
]

I've added the Docker container to IBM Cloud Functions

What would be the best way to approach this?

question from:https://stackoverflow.com/questions/65952262/ibm-cloud-functions-how-to-run-a-docker-function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Docker images which are uploaded to IBM Cloud Functions must implement certain REST interfaces. The easiest way to achieve this is to base your container on the openwhisk/dockerskeletonimage.

Please see How to run a docker image in IBM Cloud functions? and https://github.com/iainhouston/dockerPython for more details


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...