Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. How can i get it executed in python container every time it is fetched and get the output back to local??

like image 221
santosh kumar Avatar asked Feb 19 '26 20:02

santosh kumar


1 Answers

You may do this via 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:

RUN python3 manage.py migrate

If the python code is a string maybe try using EVAL command:

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

like image 64
Ohad the Lad Avatar answered Feb 22 '26 15:02

Ohad the Lad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!