docker linux/X86 hello Example, build "FROM scratch "


lake@localhost:~/local/test-linux-docker-lake/myhello/build$ gcc -static hello.c -o hello

Instead of static link, a raw system call hello world print version is here:

https://raw.githubusercontent.com/docker-library/hello-world/master/hello.c


lake@localhost:~/local/test-linux-docker-lake/myhello/build$ cd  ..
lake@localhost:~/local/test-linux-docker-lake/myhello$ ls -l
total 12
-rw-r--r-- 1 jhula sudo   40 Dec  9 23:41 Dockerfile
drwxr-xr-x 2 jhula sudo 4096 Dec  9 23:53 build
lrwxrwxrwx 1 jhula sudo   11 Dec  9 23:48 hello -> build/hello
-rw-r--r-- 1 jhula sudo 1044 Dec  9 23:54 readme.txt


lake@localhost:~/local/test-linux-docker-lake/myhello$ cat Dockerfile
FROM scratch   <<<<< Base  Image !!!
ADD hello /
CMD ["/hello"]
 

lake@localhost:~/local/test-linux-docker-lake/myhello$ docker build --tag hello  .
Sending build context to Docker daemon  917.5kB
Step 1/3 : FROM scratch
 --->
Step 2/3 : ADD hello /
 ---> ca639f6465b4
Step 3/3 : CMD ["/hello"]
 ---> Running in d0e4458fdf32
Removing intermediate container d0e4458fdf32
 ---> 92c78963cad5
Successfully built 92c78963cad5
Successfully tagged hello:latest
lake@localhost:~/local/test-linux-docker-lake/myhello$ docker  images
REPOSITORY                                                TAG                 IMAGE ID            CREATED             SIZE
hello                                                     latest              92c78963cad5        8 seconds ago       913kB

lake@localhost:~/local/test-linux-docker-lake/myhello$  docker run     hello
Hello


### dock image file
lake@localhost:~/local/test-linux-docker-lake/myhello$ sudo  find /var/lib/docker  -name  92c78963cad5*
/var/lib/docker/image/aufs/imagedb/metadata/sha256/92c78963cad51a2e845dfb858a570d4909c7212241065e1243cfeb4f7a2ef615
/var/lib/docker/image/aufs/imagedb/content/sha256/92c78963cad51a2e845dfb858a570d4909c7212241065e1243cfeb4f7a2ef615

~
 

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