0

Recently I created an ECS cluster. I used the wizard on the AWS console to create it using an existing VPC, subnets, keypair and a previously created IAM role (from another cluster creation operation). Then I proceeded to create a service using a task definition that has a group of 4 docker containers that run in a network continuously as a daemon (I'm trying to manually create a docker compose like deployment). When I create the service, the "events tab" shows that the service has reached a stable state, but no instances are running. I'm at a loss, what could be happening here?

Eddysanoli
  • 101
  • 1

1 Answers1

0

Are you by any chance deploying on Fargate? If you deploy tasks on Fargate you don't need any EC2 container instance joining the cluster. Also, given you mention Docker Compose, you may be interested in this?

mreferre
  • 426
  • 1
  • 5
  • I'm trying to do it with EC2 as a first experiment, and tried the method in the link. I was able to create a working deployment! Thanks! However, now my postgres database is crashing on startup and causing my entire service to go down because of the error `FATAL: role "root" does not exist`. It seems to be related to the fact that I haven't provided a user for my database container (despite me defining the user with environment variables). Any advice? – Eddysanoli May 19 '21 at 17:57
  • Mh... I know (I think) that for stock Postgres you HAVE to pass the `POSTGRES_PASSWORD` env variable to set the password (mandatory). But I am not sure the error is related to this? – mreferre May 19 '21 at 20:08
  • Probably, but strangely I set 3 values as environment variables: `POSTGRES_USER`, `POSTGRES_PASSWORD` and `POSTGRES_DB`. For whatever reason the container seems to ignore them all and opt to go for the default user. – Eddysanoli May 19 '21 at 22:33
  • Mh. How do you pass those variables to the task? – mreferre May 20 '21 at 07:25
  • I edit my container through the ECS console and use the environment variables parameter while I'm editing my container. It's strange cause when I use `docker inspect container_id` the variables are there, but when I use `docker exec -it container_id echo $POSTGRES_USER` the output comes out empty. – Eddysanoli May 20 '21 at 14:57
  • I think you are doing it wrong somewhere. You should edit the task definition and add the variables to your container. That alone hasn't done anything until you start a new task with that new task definition version (you just edited). you don't need to exec into the container to check. You can inspect the running task from the console, expand the container and see if environment variables have been injected. – mreferre May 20 '21 at 21:00