I am trying ro run aws batch with private docker registry.Searched on google and found some links where people have suggested to use userdata in launch template and specify docker login there.But my issue is my organization’s docker registry is using certificate also to login. In my local machine I am placing certificate in /etc/docker/cert.d/dockerhost:port location which is working fine.However, if I try to do same in userdata in ec2 it says no directory like /etc/docker…
Not sure how to use private docker registry here.
If anyone has any solution or suggestion please help.
Note: I tried from few links and got it done, posted the solution in answer.
2
Answers
Just an update to anyone who is trying the same:
If you need certificate for docker registry i.e if the connection is SSL then you need to put the certificate at directory /etc/docker/certs.d/dockerhostname:port/.
When AWS batch instantiates the EC2 box, it has docker preinstalled and you can do the required changes in userdata script in order to fetch image from private repository that works in SSL connection:
This link explain and solve your problem. It worked for me:
https://aws.amazon.com/blogs/compute/how-to-authenticate-private-container-registries-using-aws-batch/
Only for ec2 on-demand and not valid for fargate, if you your solution involve the latter(fargate) then if you don want tricky solutions I guess you’ll need push your image from Docker to AWS ECR