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:
       - [email protected]
       - 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"]
4
  • I'm uncertain if I understand the question entirely. Are you trying to find some way to input values into compose? Like this? stackoverflow.com/a/43545223/3188654 Commented Aug 7, 2023 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 Commented Aug 8, 2023 at 5: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? Commented Aug 8, 2023 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. Commented Aug 9, 2023 at 7:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.