携手创作,共同成长!这是我参与「掘金日新计划 · 8 月更文挑战」的第19天,点击查看活动详情
若看到相同文章,为本人其他平台
docker-ce编译
一、环境搭建
docker的编译,需要在宿主机预先安装docker软件。因为编译docker的源码时,会构建一个docker镜像并运行,在这个容器里面进行build操作。由于这个容器已经包含了go语言环境,故宿主机无须额外安装golang。 宿主机系统:uos 宿主机docker版本:Docker version 19.03.8, build 1b4342cd4c
二、下载源码
docker的github官方网站为:github.com/docker/dock… docker以每月发布一个版本的节奏进行开发。命名规则为:年份-月份-ce,其中ce表示社区版本。截至本文撰写时,最新版本为v17.12.0-ce,但下一版本v18.01.0-ce-dev已经处于开发阶段(带dev表示开发阶段),本文编译得到的版本即为v18.01.0-ce-dev。 发行版本下载地址:github.com/docker/dock… 本文在/home/latelee/docker/dev目录进行,请根据实际情况修改目录。 下载源码:
git clone https://github.com/docker/docker-ce
#或者
git clone https://gitee.com/ruog/docker-ce.git
进入docker-ce目录:
cd docker-ce
切换到最新的tag:
git checkout -b v18.01.0-ce
最后编译通过用的该命令:
在/home/hao/docker_work/docker-ce文件夹下执行该命令:
make VERSION=18.01.0-ce-dev ENGINE_DIR=/home/hao/docker_work/docker-ce/components/engine CLI_DIR=/home/hao/docker_work/docker-ce/components/cli deb
make VERSION=18.01.0-ce-dev ENGINE_DIR=/root/docker-ce/components/engine CLI_DIR=/root/docker-ce/components/cli deb
如果编译不通过,试试make clean.
命令解释: 该命令指定了版本号和docker组件的目录(VERSION、ENGINE、CLI分别指版本号、docker引擎、docker命令行),同时指定了要编译的系统版本(deb指编译所有debian平台包,ubuntu16.04代号为xenial).
大约经过半小时(github上下载速度为3m/s的情况下),编译成功。最终生成的deb包位于:components\packaging\deb\debbuild\ubuntu-xenial
和其他各deb下的版本文件夹中.
6.编译出来的docker-ce安装
安装docker-ce的deb包时出现依赖库的问题,如下图所示:
从图说明containerd.io库需要>=1.4.1版本.
containerd.io#在该地址找到ubuntu16.04的库, 16.04的代号为Xenial Xerus (好客的非洲地松鼠). 但这个最新只有1.3.7版本的.
https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/
#在提前体验包中发现1.4.1版本的.
https://download.docker.com/linux/ubuntu/dists/xenial/pool/nightly/amd64/
wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/nightly/amd64/containerd.io_1.4.1-1_amd64.deb
#containerd.io库1.4.1源码: 是containerd工程,不是containerd.io.
wget https://github.com/containerd/containerd/archive/v1.4.1.zip
#github上的地址
https://github.com/containerd/containerd/tree/v1.4.1
7.修改的目录
./components/packaging/plugins/app.installer
./components/packaging/plugins/buildx.installer
./components/engine/hack/dockerfile/install/proxy.installer
./components/engine/hack/dockerfile/install/runc.installer
./components/engine/hack/dockerfile/install/tini.installer
./components/engine/hack/dockerfile/install/gotestsum.installer
./components/engine/hack/dockerfile/install/tomlv.installer
./components/engine/hack/dockerfile/install/golangci_lint.installer
./components/engine/hack/dockerfile/install/rootlesskit.installer
./components/engine/hack/dockerfile/install/dockercli.installer
./components/engine/hack/dockerfile/install/containerd.installer
./components/engine/hack/dockerfile/install/vndr.installer
./components/engine/hack/dockerfile/install/shfmt.installer
最后直接编译二进制文件进行替换的.