Reputation: 12433
I have docker file which make image.
FROM public.ecr.aws/lambda/python:3.9
RUN export LANG=en_US.UTF-8
RUN export PYTHONUNBUFFERED=1
docker build -f dockers/mydocker -t python .
then I would like to make images from this image.
There are listed image named basic docker images
Then in another Dockerfile.
FROM python
ADD ./Pipfile* ./
RUN pipenv install --ignore-pipfile
When I try to build this dockerfile
There comes like this
FROM docker.io/library/python
Does this mean I can use local image to build next image?
I need to make local repository for this purpose ??
Or any other way to do this??
Upvotes: 0
Views: 9706
Reputation: 158956
This is probably working fine, but you should be careful to pick names that don't conflict with standard Docker Hub image names.
A Docker image name has the form registry.example.com/path/name
. If you don't explicitly specify a registry, it always defaults to docker.io
(this can't be changed), and if you don't specify a path either, it defaults to docker.io/library/name
. This is true in all contexts – the docker build -t
option, the docker run
image name, Dockerfile FROM
lines, and anywhere else an image name appears.
That means that, when you run docker build -t python
, you're creating a local image that has the same name as the Docker Hub python
image. The docker build
diagnostics are showing you the expanded name. It should actually be based on your local image, though; Docker won't contact a remote registry unless the image is missing locally or you explicitly tell it to.
I'd recommend choosing some unambiguous name here. You don't specifically need a Docker Hub account, but try to avoid bare names that will conflict with standard images.
# this will work even if you don't "own" this Docker Hub name
docker build -f Dockerfile.base -t whitebear/python .
FROM whitebear/python
...
(You may have some trouble seeing the effects of your base image since RUN export
doesn't do anything; change those lines in the base image to ENV
instead.)
Upvotes: 5