Search code examples
amazon-ec2dockerdockerhubamazon-ecs

Running a Docker Image stored in a EC2 Container Instance


I am using an EC2 Container Instance to build my docker image. Then i would like to use the ECS Service, to schedule a task. My image is already presented in a EC2 Container Instance.

Do i need to push it to the Docker Hub?

Or Can I run this image directly from EC2 Container instance?

And is there a best practice?


Solution

  • One good practice is to build your image once, push it to a registry and then each time you want to run your container you can just pull your image (instead of building it on EC2 or ECS).

    This ensure consistency as all your container will use the exact same image.

    You can store it on Docker Hub or use Amazon EC2 container registry to store your image.