0

I am trying to get keyboard input with the cmd and according to the variable, I will do some calculations in the python file. Since I have 2 services in my docker yml file, I can't use the docker-compose run option. Is there a way to do it.

My docker compose file is:

services:
  postgres:
   image: postgres:13
   environment:
     - POSTGRES_USER=postgres
     - POSTGRES_PASSWORD=postgres
   ports:
     - "5432:5432"



   pg-admin:
     image: dpage/pgadmin4:6
     environment:
       - PGADMIN_DEFAULT_EMAIL=admin@email.com
       - PGADMIN_DEFAULT_PASSWORD=admin
       - PGADMIN_LISTEN_PORT=5050

ports:
  - "5050:5050"


   pythonapp:
      build: ./
      tty: true
      stdin_open: true
      command: python3 ./main.py

Dockerfile :

FROM python:3.8

COPY requirements.txt .

RUN pip install -r requirements.txt

COPY main.py ./


ENTRYPOINT ["python", "main.py"]
Qdadedalus
  • 91
  • 1
  • 7
  • I'm uncertain if I understand the question entirely. Are you trying to find some way to input values into compose? Like this? https://stackoverflow.com/a/43545223/3188654 – Pronex Aug 07 '23 at 21:01
  • No actually I have a python script which asks for a input from user. How can I prompt the input via cmd – Qdadedalus Aug 08 '23 at 05:29
  • I guess the most straightforward solution would be to write a python script that asks for user input (`input("please type the value for ARG")`) and then runs docker compose. No? Or do you have a restriction on doing this? – Pronex Aug 08 '23 at 13:36
  • Yes I was doing the same thing but somehow it does not ask for user input. I have postgres service also in the container maybe it causes that. – Qdadedalus Aug 09 '23 at 07:16

0 Answers0