emi
emi

Reputation: 2950

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?

Upvotes: 7

Views: 35491

Answers (2)

Robert
Robert

Reputation: 36843

You should:

FROM IMAGE_ID

Or, this is already ok:

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

Where SOME_HEX_VALUE is the tag version (the second column in docker images). Note that if the images is present in your computer, docker won't try to pull it again.

Upvotes: 0

larsks
larsks

Reputation: 312400

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

Upvotes: 8

Related Questions