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?
AWS Elastic Container Service (ECS) can pull images from Docker Hub and manage container workload with low-cost AWS Fargate clusters.
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.
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).
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:
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With