Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pulling from a local docker image instead

I have an app with a Dockerfile content that looks like

Dockerfile

FROM SOME_NUMBERS.dkr.ecr.us-east-1.amazonaws.com/app_name:SOME_HEX_VALUE

COPY docker/app/bin/startup.sh /usr/bin/

CMD ["/usr/bin/startup.sh"]

I don't want to pull the image from amazon anymore instead I'd like to "pull" from the already-existing local image pulled the after the first docker-compose up --build command was ran.

When I do docker images I get

SOME_NUMBERS.dkr.ecr.us-east-1.amazonaws.com/app_name SOME_HEX_VALUE SOMESHORT_HEX 2 days ago 1.54 GB which means the image is local already. I understand this

if the host has the image you want docker-compose to use on it it will use that image but if the host doesn't have it, it will go to docker hub or whatever you have setup in your config for registries

So I changed the Dockerfile content to this:

FROM IMAGE_ID:SOME_HEX_VALUE where IMAGE_ID is the image id of the repository I want when I do docker images but then I get Service 'app' failed to build: repository SOMESHORT_HEX not found: does not exist or no pull access and I'd like to know how to tell Docker to use the local image instead of trying to pull from the amazon url. Any ideas?

like image 818
emi Avatar asked Aug 03 '26 02:08

emi


1 Answers

First pull the images from the remote repository in your local Docker engine:

docker pull SOME_NUMBERS.dkr.ecr.us-east-1.amazonaws.com/app_name:SOME_HEX_VALUE

Now, give the image a new local tag:

docker tag SOME_NUMBERS.dkr.ecr.us-east-1.amazonaws.com/app_name:SOME_HEX_VALUE my-image-name

Now you can simply refer to my-image-name, as in:

FROM my-image-name
like image 199
larsks Avatar answered Aug 05 '26 17:08

larsks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!