How to Compile Docker from Source?
Docker的开源部分被改名成了Moby,同时Docker公司还开源了一个LinuxKit的项目,大家可以先去看一下readme。
参考链接
https://github.com/collabnix/dockerlabs/blob/master/beginners/compiling-docker-from-source.md
先确定 操作系统版本,安装的docker的版本
Ubuntu 18.04.6 LTS
lsb_release -a
1 2 3 4 5
| No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.6 LTS Release: 18.04 Codename: bionic
|
dpkg –listfiles docker-ce containerd.io
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| /. /etc /etc/default /etc/default/docker /etc/docker /etc/init /etc/init/docker.conf /etc/init.d /etc/init.d/docker /lib /lib/systemd /lib/systemd/system /lib/systemd/system/docker.service /lib/systemd/system/docker.socket /usr /usr/bin /usr/bin/docker-proxy /usr/bin/dockerd /usr/libexec /usr/libexec/docker /usr/libexec/docker/docker-init /usr/share /usr/share/doc /usr/share/doc/docker-ce /usr/share/doc/docker-ce/README.md /usr/share/doc/docker-ce/changelog.Debian.gz
/. /etc /etc/containerd /etc/containerd/config.toml /lib /lib/systemd /lib/systemd/system /lib/systemd/system/containerd.service /usr /usr/bin /usr/bin/containerd /usr/bin/containerd-shim /usr/bin/containerd-shim-runc-v1 /usr/bin/containerd-shim-runc-v2 /usr/bin/ctr /usr/bin/runc /usr/share /usr/share/doc /usr/share/doc/containerd.io /usr/share/doc/containerd.io/changelog.Debian.gz /usr/share/doc/containerd.io/copyright /usr/share/man /usr/share/man/man5 /usr/share/man/man5/containerd-config.toml.5.gz /usr/share/man/man8 /usr/share/man/man8/containerd-config.8.gz /usr/share/man/man8/containerd.8.gz /usr/share/man/man8/ctr.8.gz $
|
查看docker相关的版本号信息
1 2 3 4 5
| Docker version 24.0.2, build cb74dfc
Docker version 24.0.2, build 659604f
|
Ubuntu 20.04.4 LTS
lsb_release -a
1 2 3 4 5
| No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal
|
dpkg –listfiles docker-ce containerd.io
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| /. /etc /etc/default /etc/default/docker /etc/docker /etc/init.d /etc/init.d/docker /lib /lib/systemd /lib/systemd/system /lib/systemd/system/docker.service /lib/systemd/system/docker.socket /usr /usr/bin /usr/bin/docker-proxy /usr/bin/dockerd /usr/libexec /usr/libexec/docker /usr/libexec/docker/docker-init /usr/share /usr/share/doc /usr/share/doc/docker-ce /usr/share/doc/docker-ce/README.md /usr/share/doc/docker-ce/changelog.Debian.gz
/. /etc /etc/containerd /etc/containerd/config.toml /lib /lib/systemd /lib/systemd/system /lib/systemd/system/containerd.service /usr /usr/bin /usr/bin/containerd /usr/bin/containerd-shim /usr/bin/containerd-shim-runc-v1 /usr/bin/containerd-shim-runc-v2 /usr/bin/ctr /usr/bin/runc /usr/share /usr/share/doc /usr/share/doc/containerd.io /usr/share/doc/containerd.io/changelog.Debian.gz /usr/share/doc/containerd.io/copyright /usr/share/man /usr/share/man/man5 /usr/share/man/man5/containerd-config.toml.5.gz /usr/share/man/man8 /usr/share/man/man8/containerd-config.8.gz /usr/share/man/man8/containerd.8.gz /usr/share/man/man8/ctr.8.gz
|
查看docker相关的版本号信息
1 2 3 4 5
| docker -v Docker version 24.0.6, build ed223bc
dockerd -v Docker version 24.0.6, build 1a79695
|
1a79695 这个对应的提交:
1 2 3 4 5 6
| https://github.com/golang108/docker-moby/commit/1a79695 -> https://github.com/moby/moby/commit/1a79695
1a79695 Merge pull request moby#46366 from thaJeztah/24.0_backport_volume-loc
|
ed223bc 这个对应的提交:
1 2 3 4 5
| https://github.com/golang108/docker-cli/commit/ed223bc -> https://github.com/docker/cli/commit/ed223bc
ed223bc Merge pull request #4544 from thaJeztah/24.0_backport_fix_events_json…
|
至此就找到 命令 对应的 源码了。。。
下载对应的 docker 源码仓库
1 2 3 4 5 6 7
| git clone https://gitee.com/golang108/docker-cli.git docker # 这个是 客户端,平常我们使用的 docker 命令就来自这个仓库。
git clone https://gitee.com/golang108/docker-moby.git dockerd # 这个是 服务端,运行 dockerd 守护进程的命令就来自这个仓库。
|