AWS App Runner "Create Failed" on health check

6.4k Views Asked by At

I'm creating my first app on AWS App Runner. I have a simple nginx Docker image that works locally by serving html on localhost:8080.

When I try to deploy it, the result is "Create Failed". Upon digging into the CloudWatch logs, I see that the health check failed. The health check is configured to ping the root of the service "/" at port 8080.

5

There are 5 best solutions below

0
On BEST ANSWER

I was able to resolve this by deleting my App Runner app (this is currently the only way to change the configuration-- see this issue), then creating a new one and specifying the health check to ping port 80.

1
On
  1. Comment/remove the EXPOSE port from docker file
  2. Set port in apprunner to 80
  3. The port that your services starts on should also be 80.

i dont know why expose causes the issue.

0
On

Are you getting this error:

10-21-2021 02:13:32 PM [AppRunner] Health check on port '80' failed. Service is rolling back. Check your configured port number. For more information, read the application logs.
10-21-2021 02:07:40 PM [AppRunner] Performing health check on port '80'.
10-21-2021 02:07:30 PM [AppRunner] Provisioning instances and deploying image.
10-21-2021 02:07:20 PM [AppRunner] Successfully pulled image from ECR.
10-21-2021 02:04:58 PM [AppRunner] Service status is set to OPERATION_IN_PROGRESS.
10-21-2021 02:04:57 PM [AppRunner] Service creation started.

If you are building on an M1 mac by chance? If so that's probably the reason. The image that's being built is of the ARM architecture, and App Runner or Fargate is an x86 runtime.

Aws is working on fixing this issue here: #1949

In the meantime, there's a workaround, you can prefix copilot commands with the DOCKER_DEFAULT_PLATFORM=linux/amd64

For example:

DOCKER_DEFAULT_PLATFORM=linux/amd64 copilot deploy

So basically when you build your docker image just use:

You can use buildx (mobi) which suipport cli for platform.

docker build --platform linux/amd64 -t your-docker-image-name .

Hope that helps, and sorry for the trouble

0
On

Does your application come up fine locally when running as a docker container?

The localhost needs to point to 0.0.0.0 ip rather than 127.0.0.1 or localhost to work on apprunner

0
On

When creating the app, the default port is 8080, but the default basic nginx server listens on port 80. So, when creating the app, you should change the port to 80.