0

I am currently facing issues with deploying my Docker image on AWS. I managed to push my image into a Elastic Container Registry repository. I created an Elastic Container Service Cluster with a Task. Everything seems fine so far.

It does not start as I expect. I noticed that locally my Docker image must be executed with the "-it" argument (interactive shell).

Can you tell me how to enable such "-it" parameter?

Thanks!

Mark B
  • 183,023
  • 24
  • 297
  • 295
colletjb
  • 279
  • 3
  • 16
  • 1
    You can't do that with ECS. However I see you have tagged the question with `flask`. Are you trying to deploy a Flask app? If so, that shouldn't need to be started with an interactive shell. I suggest editing your question to provide more details, like exactly what you are trying to deploy (Dockerfile) and how you are trying to deploy it (ECS Task Definition). – Mark B Apr 26 '22 at 13:46
  • Yes, this is a Flask app. When i run it locally, i use "flask run". I also use the same on my Dockerfile: CMD ["flask", "run"]. When i start my Docker image, i must use the "-it" parameter. If i dont, it starts something else (don't know what), but it does not work the way i'd like :( – colletjb Apr 27 '22 at 07:41
  • "When i start my Docker image, i must use the "-it" parameter. If i dont, it starts something else (don't know what), but it does not work the way i'd like " Then **THAT** should be the question you post on StackOverflow to get help with. It sounds like there's something wrong with the way your docker image is being built. In any case you still haven't provided any detailed information that would be needed to answer your question, including any of the information I requested you add, so I'm voting to close the question at this time. – Mark B Apr 27 '22 at 12:05

1 Answers1

0

you can set 'initProcessEnabled' to true parameter in container definition. This will allow us to access the running container

Following doc might help :

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_linuxparameters

Once this parameter is set to true you can access running container using below cli command.

aws ecs execute-command --cluster *cluster-name* \
--region *aws-region*
--task *task-id* \
--container *container-name* \
--interactive \
--command "/bin/sh"

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html

madhura1499
  • 1
  • 1
  • 2
  • If you want to run flask app inside docker you can add following instruction in Dockerfile ` ENTRYPOINT [ "python" ] CMD [ "app.py" ] ` you can refer below post : https://stackoverflow.com/questions/41752405/running-flask-app-in-a-docker-container/46318596#46318596 – madhura1499 Jul 07 '22 at 09:08