I'm working on a dockerfile.
I just realised that I've been using FROM
with indexed images all along.
So I wonder:
- How can I use one of my local (custom) images as my base (
FROM
) image withoutpushing
it to the index?
I'm working on a dockerfile.
I just realised that I've been using FROM
with indexed images all along.
So I wonder:
FROM
) image without pushing
it to the index?
You can use it without doing anything special. If you have a local image called
blah
you can doFROM blah
. If you doFROM blah
in your Dockerfile, but don't have a local image calledblah
, then Docker will try to pull it from the registry.In other words, if a Dockerfile does
FROM ubuntu
, but you have a local image calledubuntu
different from the official one, your image will override it.Verified: it works well in Docker 1.7.0.
BTW, don't specify
--pull=true
when running thedocker build
command:-https://github.com/docker/docker/issues/14943
Remember to put not only the tag but also the repository in which that tag is, this way:
You should reference it this way:
You can have - characters in your images. Assume you have a local image (not a local registry) named centos-base-image with tag 7.3.1611.
Dockerfile
Result
In the example above
FROM
is fetching your local image, you can provide additional instructions to fetch an image from your custom registry (e.g.FROM localhost:5000/my-image:with.tag
). See https://docs.docker.com/engine/reference/commandline/pull/#pull-from-a-different-registry and https://docs.docker.com/registry/#tldrFinally, if your image is not being resolved when providing a name, try adding a tag to the image when you create it
This GitHub thread describes a similar issue of not finding local images by name.