How to use a base image for docker and build your own image out of it?

203 Views Asked by At

I have found a docker image that has everything i need to setup my application but its large to download so that's why i'm trying to download it to AWS ECR so that the build process can speed up is there any way i can pull docker image and use that as a base to build my own?

Thanks

1

There are 1 best solutions below

0
xwlee On BEST ANSWER

You can pull the image and push it to AWS ECR. You need to create the repo in AWS first. enter image description here

# Tag your image so you can push the image to this repository
docker tag <image_name>:latest <account_id>.dkr.ecr.<region>.amazonaws.com/<repo_name>:latest
# Push this image to your AWS repository
docker push <account_id>.dkr.ecr.<region>.amazonaws.com/<repo_name>:latest

Yes, you can use any image as base image. You can use the image you push to AWS ECR too, at the top of your Dockerfile add below code:

FROM <account_id>.dkr.ecr.<region>.amazonaws.com/<repo_name>:<image_tag>