3

I created docker a docker image of a spring boot application using the below command

docker build -f Dockerfile -t myimage

once i run the command "docker images" I see that image. Now I want to get that image out my local machine and run on another machine using the below command.

docker run -p 8085:8085 myimage

What are the steps to relocate docker image to another machine over a physical medium?

/var/lib/docker/images/overlay2/imagedb/content

but that local contain .txt files of 6KB. I know normally a docker image is around 600MB in size.

Could anyone please help me to find the exact location.

Thank you

not 0x12
  • 19,360
  • 22
  • 67
  • 133
Dhanushka Sampath
  • 217
  • 1
  • 5
  • 17
  • 1
    Possible duplicate of [How to save all docker images and copy to another machine?](https://stackoverflow.com/questions/35575674/how-to-save-all-docker-images-and-copy-to-another-machine) – David Maze Aug 22 '18 at 10:27
  • I'd never poke around by hand in `/var/lib/docker` for anything. Good options include `docker push` the image to some registry, check out your source repository and `docker build` on the target machine, or `docker save`/`docker load`. – David Maze Aug 22 '18 at 10:29
  • Possible duplicate of [How to share my Docker-Image without using the Docker-Hub?](https://stackoverflow.com/questions/24482822/how-to-share-my-docker-image-without-using-the-docker-hub) – leopal Aug 22 '18 at 12:24

1 Answers1

7

1.You can export your docker image after building it.

docker build -f Dockerfile -t myimage .

docker save myimage > myimage.tar You will see this in your directory where you execute docker build command.

Then you can load it anywhere else as

docker load < myimage.tar

Other than that if there is a docker repo , you can simply push the docker image.

Reference:- https://docs.docker.com/engine/reference/commandline/export/#options

2.If the other machine can be reachable via a network you can setup the other machine as a docker hub

not 0x12
  • 19,360
  • 22
  • 67
  • 133