Linux/X86/Docker image-save-load-example-lake

Example image hello:   https://blog.csdn.net/hushui/article/details/103459550

##  image save 

lake@localhost:~/local/edgex/docker-edgex$ sudo docker save -o         ~/tmp/hello.tar    lakehudocker/hello

lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$  docker  ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$ docker image  ls
REPOSITORY                                                TAG                 IMAGE ID            CREATED             SIZE
lakehudocker/hello                                        latest              92c78963cad5        22 hours ago        913kB
hello                                                     latest              92c78963cad5        22 hours ago        913kB

lake@localhost:~/local/edgex/docker-edgex$ sudo  chown      jhula.jhula    ~/tmp/hello.tar
lake@localhost:~/local/edgex/docker-edgex$ cd  ~/tmp/


lake@localhost:~/tmp$ mkdir hello
lake@localhost:~/tmp$ cd hello/
lake@localhost:~/tmp/hello$ tar xf ../hello.tar
lake@localhost:~/tmp/hello$ ls
92c78963cad51a2e845dfb858a570d4909c7212241065e1243cfeb4f7a2ef615.json  manifest.json
d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed       repositories
lake@localhost:~/tmp/hello$ cd d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed/
lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$ ls
VERSION  json  layer.tar
lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$ tar xf layer.tar
lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$ ls
VERSION  hello  json  layer.tar
lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$ file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=ec220e630ed1d5367c165c11e8a4cf09dc0620c0, not stripped

lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$ diff hello   ~/local/edgex/test-linux-docker-lake/
cloud-lab/                      linux-lab-docker-test-lake.txt  myhello/
lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$ diff hello   ~/local/edgex/test-linux-docker-lake/myhello/hello
lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$

##  image remove  
lake@localhost:~/$ docker  rmi      lakehudocker/hello:latest
Untagged: lakehudocker/hello:latest
Untagged: lakehudocker/hello@sha256:9a128505bf51003c9539a462e6b6b28939ac29c85fcac3bc901ee28f194c6722
lake@localhost:~/tmp/hello/d83bba2ee492d1322e4c0f92cc2261f18bc7de52937decd7627b5ce2c45cf2ed$ docker image  ls
REPOSITORY                                                TAG                 IMAGE ID            CREATED             SIZE
hello                                                     latest              92c78963cad5        22 hours ago        913kB


lake@localhost:~/
Deleted: sha256:92c78963cad51a2e845dfb858a570d4909c7212241065e1243cfeb4f7a2ef615
Deleted: sha256:ca639f6465b4fa4ae34523278ce51d6cbdb5d266ff88d1656fe042ee2ec37da0
Deleted: sha256:b462d9a7f85c21a795ed453cf3bee4c5b8dd495c65bbc501ded37b9a13de4a1c


##  image    Load  back  

lake@localhost:~/local/edgex$ sudo docker load   <~/tmp/hello.tar
[sudo] password for jhula:
b462d9a7f85c: Loading layer [==================================================>]  914.4kB/914.4kB
Loaded image: lakehudocker/hello:latest 
lake@localhost:~/local/edgex$ docker image  ls
REPOSITORY                                                TAG                 IMAGE ID            CREATED             SIZE
lakehudocker/hello                                        latest              92c78963cad5        22 hours ago        913kB
 

 

###  Note  docker run means docker create (new container)  & docker start 
 lake@localhost:~/local/edgex$ docker run    lakehudocker/hello:latest
Hello
 lake@localhost:~/local/edgex$ docker ps -a
CONTAINER ID        IMAGE                                                     COMMAND                  CREATED             STATUS                      PORTS               NAMES
556460081fd1        lakehudocker/hello:latest                                 "/hello"                 8 seconds ago       Exited (0) 7 seconds ago                        suspicious_mccarthy

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章