0

currently we are using docker 19.03.15;

  • we use docker build -t test:test . to get image test:test (docker image history test:test A)
  • we use docker save -o out.tar test:test to get out.tar
  • we use docker rmi test:test to remove original image
  • we use docker load -i out.tar to get test:test back (docker image history test:test B)

and for the probe of A and B of docker image history, we find that at B, there is only one image layer meanwhile the others are <missing>; checked in docker run and all contents are there, which means that docker combine all layers into one!

my question is: How to tell docker to load image from the tar ball and keep the layers?

for layer, I mean, where there is a command in Dockerfile, there is a layer, e.g.

FROM ubuntu:20.04

RUN apt-get update && apt-get install -y vim # create one layer
RUN apt-get install -y python3               # create another layer

after docker build, use docker image history can see

IMAGE      | CREATED BY
hash1      | |0 /bin/sh -c apt-get install -y python3
hash2      | |0 /bin/sh -c apt-get update && apt-get install -y vim
hash3      | ... (base image last command)
<missing>  | ...

after docker load, docker image history will show

IMAGE      | CREATED BY
hashx      | |0 /bin/sh -c apt-get install -y python3
<missing>  | |0 /bin/sh -c apt-get update && apt-get install -y vim
<missing>  | ... (base image last command)
<missing>  | ...
Doz Parp
  • 279
  • 4
  • 23

1 Answers1

0

hacker way: we can directly operate in /var/lib/docker to dump image data and remove layers that we want.

Doz Parp
  • 279
  • 4
  • 23