์ฌํ ๋จ๊ณ :
๋ณต์ฌ:
gg7<strong i="8">@gg7</strong>:~$ mkdir docker-mtime-test
gg7<strong i="9">@gg7</strong>:~$ cd docker-mtime-test
gg7<strong i="10">@gg7</strong>:~/docker-mtime-test$ touch example-file
gg7<strong i="11">@gg7</strong>:~/docker-mtime-test$ stat example-file
File: โexample-fileโ
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fc01h/64513d Inode: 7602338 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1001/ gg7) Gid: ( 1001/ gg7)
Access: 2015-10-19 14:13:28.441785563 +0100
Modify: 2015-10-19 14:13:28.441785563 +0100
Change: 2015-10-19 14:13:28.441785563 +0100
Birth: -
gg7<strong i="12">@gg7</strong>:~/docker-mtime-test$ cat > Dockerfile <<EOF
FROM ubuntu:14.04
COPY example-file /example-file
RUN stat /example-file
EOF
gg7<strong i="13">@gg7</strong>:~/docker-mtime-test$ docker build --no-cache -t docker-mtime-test .
Sending build context to Docker daemon 2.56 kB
Step 0 : FROM ubuntu:14.04
---> fa81ed084842
Step 1 : COPY example-file /example-file
---> 8212ccaf4c14
Removing intermediate container cece2b393603
Step 2 : RUN stat /example-file
---> Running in 86bd29f2fa49
File: '/example-file'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 6ch/108d Inode: 43 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2015-10-19 13:15:27.415707557 +0000
Modify: 2015-10-19 13:13:28.000000000 +0000
Change: 2015-10-19 13:15:27.415707557 +0000
Birth: -
---> cb0e1fdb58bd
Removing intermediate container 86bd29f2fa49
Successfully built cb0e1fdb58bd
์ค์ ๊ฒฐ๊ณผ :์ ์์ ์๊ฐ /example-file
๋ ๊ฒ์ผ๋ก๋ณด๊ณ ์๋ค 2015-10-19 13:13:28.000000000 +0000
.
์์ ๊ฒฐ๊ณผ :์ ์์ ์๊ฐ /example-file
๋์ด์ผํฉ๋๋ค 2015-10-19 13:13:28.441785563 +0000
.
docker-commit
:
gg7<strong i="26">@gg7</strong>:~$ docker run -it --name mtime-test ubuntu:14.04 /bin/bash
root<strong i="27">@613e6c0fe6ac</strong>:/# touch /example-file
root<strong i="28">@613e6c0fe6ac</strong>:/# stat /example-file
File: '/example-file'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 66h/102d Inode: 72 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2015-10-19 13:36:29.888088708 +0000
Modify: 2015-10-19 13:36:29.888088708 +0000
Change: 2015-10-19 13:36:29.888088708 +0000
Birth: -
root<strong i="29">@613e6c0fe6ac</strong>:/# exit
exit
gg7<strong i="30">@gg7</strong>:~$ docker commit mtime-test mtime-test-image
b67d16fcb577fb3ece29cf007f1cef2ebc4a6351bc3e3a3e77eab5648461095c
gg7<strong i="31">@gg7</strong>:~$ docker run -it --name mtime-test-2 mtime-test-image /bin/bash
root<strong i="32">@1a5e038e6a2c</strong>:/# stat /example-file
File: '/example-file'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 66h/102d Inode: 75 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2015-10-19 13:36:55.572503813 +0000
Modify: 2015-10-19 13:36:29.000000000 +0000
Change: 2015-10-19 13:36:55.572503813 +0000
Birth: -
root<strong i="33">@1a5e038e6a2c</strong>:/#
์ด๊ฒ์ด ์ ์ค์ํ๊ฐ?
์ผ๋ถ ๋น๋ ์์คํ ์ ์์ ํ์์คํฌํ์ ์์กดํ์ฌ ํ์ผ ์ ๋ฐ์ดํธ๋ฅผ ๊ฐ์งํฉ๋๋ค.
ํ๊ฒฝ ์ธ๋ถ ์ ๋ณด :
cat /etc/lsb-release
:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"
uname -a
:
Linux gg7 3.13.0-51-generic #84-Ubuntu SMP Wed Apr 15 12:08:34 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
docker version
:
Client:
Version: 1.8.3
API version: 1.20
Go version: go1.4.2
Git commit: f4bf5c7
Built: Mon Oct 12 05:37:18 UTC 2015
OS/Arch: linux/amd64
Server:
Version: 1.8.3
API version: 1.20
Go version: go1.4.2
Git commit: f4bf5c7
Built: Mon Oct 12 05:37:18 UTC 2015
OS/Arch: linux/amd64
docker info
:
Containers: 8
Images: 632
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 656
Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.13.0-51-generic
Operating System: Ubuntu 14.04.3 LTS
CPUs: 8
Total Memory: 15.66 GiB
Name: gg7
ID: ACSH:EYI5:G36O:2SRA:FWLH:U4GF:VMJM:C4KF:73MH:L273:TCCO:GW3K
WARNING: No swap limit support
์ค๋ ๋ฐฉ๊ธ ์ด๊ฒ์ ๋ถ๋ช์ณค์ต๋๋ค.
์๊ฐํ ์ ์๋ ์ ์ผํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ํ์ผ์ ๋ฌด๊ฒ๋ฅผ ์ธก์ ํ๊ณ ๋ณต์ฌํ๊ณ ๋ค์ ์์ถ์ ํธ๋ ๊ฒ์ ๋๋ค...
UPDATE ์ถ๊ฐ tar ์์ ์ผ๋ก ์ธํด ์ ๋ฐ์ ์ผ๋ก ์๋๊ฐ ๋๋ ค์ก์ต๋๋ค.
์ด ๋ฌธ์ ๊ฐ ๋๋ฌด ์ค๋ซ๋์ ์ด๋ ค ์์๊ธฐ ๋๋ฌธ์ Docker์์ ์์ ํ๊ธฐ ์ด๋ ค์ธ ์ ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค. COPY
๋์ ํ์์คํฌํ๋ฅผ ์ ์งํ๋ ๊ฒ์ด ์ ์ด๋ ค์ด์ง ๊ถ๊ธํฉ๋๋ค.
์ด ๋ฒ๊ทธ๋ "COPY --from"์ ์ฌ์ฉํ์ฌ ๊ธฐ์กด ๋จ๊ณ์์ ํ์ํ ๋ถ๋ถ๋ง ์ ํํ๋ ๊ฒ์ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ถ๊ฐ๋ฅํ๊ฒ ๋ง๋ญ๋๋ค. ์๋ํ๋ฉด ํ ๋๋ง๋ค ํ์ ์งํฉ์์ ๋ฌด์ธ๊ฐ๋ฅผ ์๋ง์ผ๋ก ๋ง๋ค๊ธฐ ๋๋ฌธ์ ๋๋ค.
์ผ๋ฐ์ ์ผ๋ก tar ๋ฐ co์ ๊ฐ์ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ๊ณ ์ถ์ง ์์ ๊ฒ์ ์์ฑํ๋ ๊ฒฝ์ฐ(tar์ ์์ฑ์์ธ ๊ฒฝ์ฐ๋ฅผ ์ ์ธํ๊ณ ) tar ํด๊ฒฐ ๋ฐฉ๋ฒ๋ ํดํน์ ๋๋ค.
๋ํ ๋์ปค ์ด๋ฏธ์ง ๋ด๋ถ์ ํ์์คํฌํ๋ฅผ ๋ณด์กดํ๊ฑฐ๋ ์์ ํ๊ธฐ ์ํด ๋ค๋ฅธ ๊ฒ์ ์ฌ์ฉํ๋ค๊ณ ๊ฐ์ ํด ๋ณด๊ฒ ์ต๋๋ค. ์ด์ ๋์ปค ์ด๋ฏธ์ง ํฌ๊ธฐ๋ ๋ ๋ฐฐ์ ๋๋ค.
๋ฐ๋ผ์ ํ์์คํฌํ๋ฅผ ๋ณด์กดํ๋ ๊ธฐ๋ฅ์ด ํ์ํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ค๋ ๋ฐฉ๊ธ ์ด๊ฒ์ ๋ถ๋ช์ณค์ต๋๋ค.
์๊ฐํ ์ ์๋ ์ ์ผํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ํ์ผ์ ๋ฌด๊ฒ๋ฅผ ์ธก์ ํ๊ณ ๋ณต์ฌํ๊ณ ๋ค์ ์์ถ์ ํธ๋ ๊ฒ์ ๋๋ค...
UPDATE ์ถ๊ฐ tar ์์ ์ผ๋ก ์ธํด ์ ๋ฐ์ ์ผ๋ก ์๋๊ฐ ๋๋ ค์ก์ต๋๋ค.