博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
『中级篇』手动建立一个base Image(14)
阅读量:7093 次
发布时间:2019-06-28

本文共 901 字,大约阅读时间需要 3 分钟。

这篇文章主要介绍了Docker Base Image创建具体实现的相关资料,这里提供了详细的具体步骤,需要的朋友可以参考下github:

如何制作一个base Image

base Image 之前讲过2种方式一种是通过pull docker官网获得,另一种是通过build的方式来获得。自己制作肯定是通过base Image的方式。

  • 通过pull的方式
    docker pull hello-worlddocker image lsdocker run hello-world

『中级篇』手动建立一个base Image(14)

『中级篇』手动建立一个base Image(14)

  • 通过build的方式
    1.创建文件
    mkdir hello-worldcd hello-world/vim hello.c

    『中级篇』手动建立一个base Image(14)

2.编辑c文件

#include
int main(){ printf("hello docker 微信公众号:编程坑太多\n");}

image.png

3.编译程序gcc

sudo yum install -y gccsudo yum install -y glibc-static gcc -static hello.c -o hello

image.png

『中级篇』手动建立一个base Image(14)

4.创建编辑Dockerfile

vim Dockfile

『中级篇』手动建立一个base Image(14)

FROM scratchADD hello /CMD ["/hello"]

『中级篇』手动建立一个base Image(14)

docker build -t liming/hello .

image.png

『中级篇』手动建立一个base Image(14)

#查看分层layer   docker history a4cb86cc8d6b

『中级篇』手动建立一个base Image(14)

5.运行Image

docker run liming/hellodocker container ls -a

『中级篇』手动建立一个base Image(14)

『中级篇』手动建立一个base Image(14)

  • 个人主页:idig8.com

PS:hello.c 因为是c语言写的,我们把它打成一个Image,Image里面其实就是一个可以执行的文件,它其实依赖宿主机kernel,它虽然比较小,但是也能反映docker的架构,后面我们会使用mysql,nginx,tomcat其实他们的原理跟今天做的baseImage 里面的hello 程序是一样的。

往期精彩

image

转载于:https://blog.51cto.com/12040702/2151981

你可能感兴趣的文章
34hibernate_fetch_5_set_subselect
查看>>
七,移植linux-3.19内核
查看>>
splay(1区间翻转区间最值与区间修改)
查看>>
通过 openURL 方法跳转至设置 - iOS
查看>>
自定义listVew +simpleAdapter
查看>>
从win7到mac os再到win10,体验总结
查看>>
函数名的使⽤以及第⼀类对象 闭包 迭代器
查看>>
leetcode986
查看>>
leetcode894
查看>>
JS OffsetParent属性
查看>>
001——vue.js初始安装:
查看>>
《Linux程序设计》笔记(一)入门
查看>>
DesUtils工具类
查看>>
mysql中模糊查询的四种用法介绍
查看>>
使用jetty-maven-plugin插件进行测试
查看>>
swift 实践- 11 -- UISlider
查看>>
定制化自己的itchat
查看>>
爬虫之聚焦爬虫与验证码处理
查看>>
Codeforces Round #376 (Div. 2) C D F
查看>>
聪聪可可【国家集训队】
查看>>