简体   繁体   English

如何将 python 文件发送到 docker 容器(使用 python 映像)并获取 Z78E6221F6393D1356681 到本地的 DB398DZF

[英]how to send python file to docker container(using python image) and get the output back to local

i have a program which fetches the python code as string.我有一个程序将 python 代码作为字符串获取。 How can i get it executed in python container every time it is fetched and get the output back to local??每次获取它并让 output 回到本地时,我怎样才能让它在 python 容器中执行?

You may do this via docker yml (docker-copose)您可以通过 docker yml (docker-copose) 执行此操作

services:
  server:
    command: bash -c "python3 manage.py migrate; python3 manage.py runserver 0.0.0.0:8000; tail -f /dev/null;"
    ports:
      - "8000:8000"

Or in Dockerfile:或在 Dockerfile 中:

RUN python3 manage.py migrate

If the python code is a string maybe try using EVAL command:如果 python 代码是字符串,可以尝试使用 EVAL 命令:

https://www.programiz.com/python-programming/methods/built-in/eval https://www.programiz.com/python-programming/methods/built-in/eval

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python 在带有本地 SMTP 服务器的 docker 容器内发送邮件 - Python send mail inside docker container with local SMTP server 使用docker sdk for python将docker容器内的shell脚本的输出捕获到文件中) - Capture output of a shell script inside a docker container to a file using docker sdk for python) 如何删除 docker 容器内 python 中的文件? - How to delete file in python inside docker container? Python3.8.5 使用 http 请求将文件从一个 docker 容器发送到另一个容器的问题 - Python3.8.5 problem to send file from one docker container to another using http request 如何通过本地 Docker 容器中的 python 应用程序从云存储桶中读取文件 - How to read a file from a cloud storage bucket via a python app in a local Docker container Docker 图像/容器中的 Python 代码混淆 - Python code obfuscation in Docker image/container 如何将控制台输出转换为 txt 文件(使用 python Flask 服务器) - How to get console output into a txt file (using python flask server) 如何使用Mutagen和python从音乐文件中获取专辑图像? - How to get album image from a music file using Mutagen and python? 如何解析 python 中的 csv 文件得到这个 output? - How to parse csv file in python to get this output? 使用Python连接到Docker容器中的MySQL - Connect to MySQL in Docker container using Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM