Home > other >  AWS EC2 instance URL unreachable when not connected to it by SSH
AWS EC2 instance URL unreachable when not connected to it by SSH

Time:10-21

I ssh into my AWS EC2 instance. I have my app deployed to that AWS EC2 instance, using Docker.

I have my docker image registered in AWS ECR (Elastic Container Registry).

in AWS EC2, I pull the image and run it using:

docker run -p 80:8080 imagename

and it runs successfully.

However, the problem is my EC2 endpoint (URL) is only reachable when I am connected to it using SSH.

The moment that I close my terminal (SSH), the EC2 instance endpoint is unreachable.

I want to have it reachable at all times as a normal website, what is a possible fix ?

CodePudding user response:

You run your docker command locally but not in the background. So once you stop that session and therefor the container it's no longer available.

Can you try running the container with this setup:

docker run -d -p 80:8080 imagename

The "-d" flag will run the container as a daemon, in the background.

CodePudding user response:

You are using Elastic Beanstalk (EB), so you have to run your application through EB own docker system as explain in docs:

  • Related