How to use local docker image as base in Dockerfile?

108 Views Asked by At

I am a complete beginner to Docker and I need some help with this.

I have a custom docker image, I want to build it and push it to the Docker hub. For that I have a Dockerfile which has the below line.

FROM customimage:tag

Now when I try to build it for multiple platform using docker buildx build and push it to my Docker hub, It is trying to get the image from the docker hub instead of using the image present locally.

How to solve this issue.

For better understanding I am attaching output to docker images command and the contents of my Dockerfile here.

(base) pranavkaushikdhara@Pranavs-MacBook-Air GitHubData_push % docker images
 REPOSITORY                    TAG       IMAGE ID       CREATED         SIZE
 dharapranavkaushik7/elastic   latest    e5f766350178   2 seconds ago   767MB
 elasticsearch                 8.11.3    23562195abe6   5 weeks ago     767MB

Dockerfile:
FROM dharapranavkaushik7/elastic:latest

Here is the output of the build command

(base) pranavkaushikdhara@Pranavs-MacBook-Air GitHubData_push % docker buildx build - 
-platform linux/amd64,linux/arm64 -t dharapranavkaushik7/elastic:latest --push .

 [+] Building 29.8s (5/5) FINISHED                                           docker-container:serene_kilby                                                                                                                        
 => [internal] booting buildkit                                                                                                                                                   
  => => pulling image moby/buildkit:buildx-stable-1                                                                                                                                    
  => => creating container buildx_buildkit_serene_kilby0                                                                                                                                
  => [internal] load build definition from Dockerfile                                                                                                                                  
  => => transferring dockerfile: 76B                                                                                                                                                    
  => ERROR [linux/arm64 internal] load metadata for 
  docker.io/dharapranavkaushik7/elastic:latest                                                                                        
  => CANCELED [linux/amd64 internal] load metadata for 
  docker.io/dharapranavkaushik7/elastic:latest                                                                                     
  => [auth] dharapranavkaushik7/elastic:pull token for registry-1.docker.io                                                                                                             
  ------
   > [linux/arm64 internal] load metadata for 
  docker.io/dharapranavkaushik7/elastic:latest:
  ------
  Dockerfile:1
  --------------------
   1 | >>> FROM dharapranavkaushik7/elastic:latest
  --------------------
  ERROR: failed to solve: dharapranavkaushik7/elastic:latest: 
  docker.io/dharapranavkaushik7/elastic:latest: not found
0

There are 0 best solutions below