1. Docker save, load
- 현재 docker local repository에 있는 docker image를 tar파일로 추출하고 다시 로드하는 명령어
- docker image를 조작하지 않고 단순히 또다른 환경으로 이관하기 위한 용도로 사용할 수 있음
- docker image를 tar 파일로 추출하고 로드하는 역할로 이미지에 변경이 있지않은 오리지널 이미지와 동일
$ docker save (image:tag) -o (file).tar
or
$ docker save (image:tag) > (file).tar
$ docker load -i (file).tar
$ docker export (container name or container id) > (container).tar
$ docker import (파일 or URL) (image:tag)
[
{
"Id": "sha256:000b57f055093807652dfe4a5a48b159f3283c724929336aaed21dae83601290",
"RepoTags": [
"192.168.2.151:13000/jupyterpackage/jupyterhub/tljh:latest",
"tljh-systemd:latest"
],
"RepoDigests": [
"192.168.2.151:13000/jupyterpackage/jupyterhub/tljh@sha256:1996857e56912ddd3c22f1c18a59d486d8a3db2d6bf6759e21d7a5d8048af392"
],
"Parent": "sha256:793b2fec2967b335e80d19c3e1638b448e7d388a16c7eab40f725985e1e33eae",
"Comment": "",
"Created": "2020-02-05T00:45:22.847616558Z",
"Container": "0bd70d1bed16a90b5543078d95f91411dca3975ac9189771d070b76f933eb155",
"ContainerConfig": {
"Hostname": "kubemaster",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/opt/tljh/hub/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TLJH_BOOTSTRAP_DEV=yes",
"TLJH_BOOTSTRAP_PIP_SPEC=/srv/src"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"/bin/bash\" \"-c\" \"exec /sbin/init --log-target=journal 3>&1\"]"
],
"Image": "sha256:793b2fec2967b335e80d19c3e1638b448e7d388a16c7eab40f725985e1e33eae",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGRTMIN+3"
},
"DockerVersion": "19.03.5",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/opt/tljh/hub/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TLJH_BOOTSTRAP_DEV=yes",
"TLJH_BOOTSTRAP_PIP_SPEC=/srv/src"
],
"Cmd": [
"/bin/bash",
"-c",
"exec /sbin/init --log-target=journal 3>&1"
],
"Image": "sha256:793b2fec2967b335e80d19c3e1638b448e7d388a16c7eab40f725985e1e33eae",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null,
"StopSignal": "SIGRTMIN+3"
},
"Architecture": "amd64",
"Os": "linux",
"Size": 274298992,
"VirtualSize": 274298992,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/a35df2529261b6734e9c9b28be0ec8f2da19d3ba1dabe5f1898b7f0959a6bee2/diff:/var/lib/docker/overlay2/9b93fe435a173b56a5e66125c9e8107203994b818d305f276985c91eb25d0f74/diff:/var/lib/docker/overlay2/2ff9bc616de54f909f06537873d2e769b5e186a7053d0ac9c3e79490b594d6b8/diff:/var/lib/docker/overlay2/4f58322c86837c3abb0113e5eb8587332aa8043d505d8b4cf96cf74b9ae97b76/diff:/var/lib/docker/overlay2/b1c9694245f004c3e0ac72644a0265fc6295f1b42489cddb936554d1d7cf23fc/diff:/var/lib/docker/overlay2/df0b89fd1b8bdd64272491aa7ecf6f5fc987a8dd67264c314315fa69a9e59d96/diff:/var/lib/docker/overlay2/03e4a35a62cce7887ce6bd238450b50425e2a2898b939bea16934227e64db8e0/diff",
"MergedDir": "/var/lib/docker/overlay2/a04c8bc2ffb37d5470c7df121ea09ef252fa0fa83cfb367f34cc09d98c547471/merged",
"UpperDir": "/var/lib/docker/overlay2/a04c8bc2ffb37d5470c7df121ea09ef252fa0fa83cfb367f34cc09d98c547471/diff",
"WorkDir": "/var/lib/docker/overlay2/a04c8bc2ffb37d5470c7df121ea09ef252fa0fa83cfb367f34cc09d98c547471/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:43c67172d1d182ca5460fc962f8f053f33028e0a3a1d423e05d91b532429e73d",
"sha256:21ec61b65b20ec53a1b7f069fd04df5acb0e75434bd3603c88467c8bfc80d9c6",
"sha256:1d0dfb259f6a31f95efcba61f0a3afa318448890610c7d9a64dc4e95f9add843",
"sha256:f55aa0bd26b801374773c103bed4479865d0e37435b848cb39d164ccb2c3ba51",
"sha256:50395ecc5afcc0ab36db7b7e50e9084a613b4d2c138aa27713a5118d2c63849f",
"sha256:a8fda65e8b5f4c0d74dd8837c4307bed27f4cd3d17624f03769cb824616379a5",
"sha256:3c6d8ec6e3141e5fc66c96cbb171ffc2c5aa2509709f6faefdf042f9d2ada3ee",
"sha256:755886c83cb21a430d651f2e7240ef94d6ec5d722cb2aa7f6e5aaaf474fcbb1c"
]
},
"Metadata": {
"LastTagTime": "2020-02-05T09:46:09.767647815+09:00"
}
}
]
여기에서 RootFS부분이 docker file의 layers부분이다."RootFS": {
"Type": "layers",
"Layers": [
"sha256:43c67172d1d182ca5460fc962f8f053f33028e0a3a1d423e05d91b532429e73d",
"sha256:21ec61b65b20ec53a1b7f069fd04df5acb0e75434bd3603c88467c8bfc80d9c6",
"sha256:1d0dfb259f6a31f95efcba61f0a3afa318448890610c7d9a64dc4e95f9add843",
"sha256:f55aa0bd26b801374773c103bed4479865d0e37435b848cb39d164ccb2c3ba51",
"sha256:50395ecc5afcc0ab36db7b7e50e9084a613b4d2c138aa27713a5118d2c63849f",
"sha256:a8fda65e8b5f4c0d74dd8837c4307bed27f4cd3d17624f03769cb824616379a5",
"sha256:3c6d8ec6e3141e5fc66c96cbb171ffc2c5aa2509709f6faefdf042f9d2ada3ee",
"sha256:755886c83cb21a430d651f2e7240ef94d6ec5d722cb2aa7f6e5aaaf474fcbb1c"
]
},
import시 이미지의 정보[
{
"Id": "sha256:416397accdf22e543315dbd9a8fdeb3f6f54ab4f009e57695495c823eb5bda62",
"RepoTags": [
"192.168.2.151:13000/jupyterhub/tljh_add_bootstrap:v1.0"
],
"RepoDigests": [],
"Parent": "",
"Comment": "Imported from -",
"Created": "2020-02-05T02:21:19.149160748Z",
"Container": "",
"ContainerConfig": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": null,
"Image": "",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"DockerVersion": "18.09.7",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": null,
"Image": "",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 2120217745,
"VirtualSize": 2120217745,
"GraphDriver": {
"Data": {
"MergedDir": "/var/lib/docker/overlay2/ef7582ee39c4246459fe63f924cb5c32230b71eae36437244947c1df11b77d86/merged",
"UpperDir": "/var/lib/docker/overlay2/ef7582ee39c4246459fe63f924cb5c32230b71eae36437244947c1df11b77d86/diff",
"WorkDir": "/var/lib/docker/overlay2/ef7582ee39c4246459fe63f924cb5c32230b71eae36437244947c1df11b77d86/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:e5fc2009202763467fc51b8976c72cc178954d265ec7d9d55caa71324818157a"
]
},
"Metadata": {
"LastTagTime": "2020-02-05T11:21:19.166191386+09:00"
}
}
]
import로 로드한 이미지의 Layer정보"RootFS": {
"Type": "layers",
"Layers": [
"sha256:e5fc2009202763467fc51b8976c72cc178954d265ec7d9d55caa71324818157a"
]
},
추가로 export / import 한 이미지를 실행하면 어떻게 될까?[root@CIServer the-littlest-jupyterhub]# docker run --privileged --detach --name=tljh-dev --publish 12000:80 --mount type=bind,source=$(pwd),target=/srv/src 192.168.2.151:13000/jupyterhub/tljh_add_bootstrap:v1.0
docker: Error response from daemon: No command specified.
See 'docker run --help'.
[root@CIServer the-littlest-jupyterhub]#
방법 1 : Docker file 작성FROM tljh_add_bootstrap:v1.0
CMD ["/bin/bash","-c","exec /sbin/init --log-target=journal 3>&1"]
방법 2: import --chanage옵션을 사용하여 필요한 정보를 주입[root@CIServer the-littlest-jupyterhub]# docker import --change 'CMD ["/bin/bash","-c","exec /sbin/init --log-target=journal 3>&1"]' tljh.tar 192.168.2.151:13000/jupyterhub/tljh_add_bootstrap:v1.0
sha256:045273611b2cb6febc9778c9a06b8f57c97e988a6757ab950fc0023592bcfd35
[root@CIServer the-littlest-jupyterhub]# docker run --privileged --detach --name=tljh-dev --publish 12000:80 --mount type=bind,source=$(pwd),target=/srv/src 192.168.2.151:13000/jupyterhub/tljh_add_bootstrap:v1.0
716291ec798118d7a1793d5da41a4c20fe8792d924929ae35ad2e357cee635f7
[root@CIServer the-littlest-jupyterhub]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
716291ec7981 192.168.2.151:13000/jupyterhub/tljh_add_bootstrap:v1.0 "/bin/bash -c 'exec …" 5 seconds ago Up 3 seconds 0.0.0.0:12000->80/tcp tljh-dev
[root@CIServer the-littlest-jupyterhub]#