Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pulling public images from Dockerhub in ECS Fargate

Tags:

amazon-ecs

When I configure my taskdefintion on my ECS Fargate cluster to pull nginx:latest it fails with

STOPPED (CannotPullContainerError: Error response from daemon)

I fail to understand what to put into the task definition field "image".

It says there "repository-url/image:tag" but apparently it's not "nginx:latest" if I want to pull the public nginx image from dockerhub. What's the repository-url of dockerhub?

like image 866
krm1 Avatar asked May 08 '19 09:05

krm1


People also ask

Can ECS use Docker Hub?

AWS Elastic Container Service (ECS) can pull images from Docker Hub and manage container workload with low-cost AWS Fargate clusters.

Do I need to login to Docker Hub to pull the images?

4 Please login prior to pull: Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.

Does Docker Hub store images or containers?

Docker Hub repositories allow you share container images with your team, customers, or the Docker community at large. Docker images are pushed to Docker Hub through the docker push command. A single Docker Hub repository can hold many Docker images (stored as tags).


1 Answers

In ECS FARGATE/EC2 when we will sepcify the image we can directly sepcify any image name which we are able to pull it via docker command.

For example if we are able to pull the latest nginx image with command docker pull nginx where if we will not specify any tag then it will pull latest image. This is the same thing in ECS so either we can specify the nginx or nginx:latest both will work. That means image name you have provided is correct.

The reason why are we seeing this error is not related to image but it might be related to the network where container running in FARGATE is not able to pull the Image.

We have to keep in mind that FARGATE always uses the AWS VPC network mode which means there are two way to run the task in FARGATE:

  1. If we are trying to run the task in public subnet then Auto-assign Public IP must be enabled and we have to make sure that public subnet route table has IGW or any other gateway which will give proper internet connectivity hich will allow the container to pull the image from public docker repo.

  2. If we are trying to run the task in private subnet then Auto-assign Public IP must be disabled and we have to make sure that private subnet route table has NAT gateway which will allow the container to pull the image from public docker repo.

[1] https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-configure-network.html

like image 80
Mech Avatar answered Sep 21 '22 23:09

Mech