侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

详解Docker源码编译安装

Docker  /  管理员 发布于 7年前   646

最近在尝试阅读Docker源码,一直想弄明白docker关于namespace等的代码的在哪,以及怎么触发。然而在阅读时发现根本找不到代码。。。想着还是先源码安装下docker,然后边运行边打印些调试信息看看再说

安装之前

Docker源码需在docker容器编译环境中编译,所以先安装docker,安装环境依旧是ubuntu14.04

echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.listsudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609Dsudo apt-get updatesudo apt-get upgradesudo apt-get install docker-engine

起初是使用apt-get install docker.io安装,但在编译源码的时候会遇到ARG错误。

安装

docker的安装命令很简单,虽然错误很多= =

apt-get install make git golanggit clone https://[email protected]/docker/dockercd dockermake buildmake binary

遇到的问题与解决方案

Unknown instruction: ARG

原因:

Docker Hub's automated build is still running Docker 1.8 and doesn't support ARG yet. There is a github issue tracking their upgrade to 1.9.

解决方案:采用安装最新的docker-engine方式

docker daemon启动失败

复制代码 代码如下:
FATA[0000] Error starting daemon: error initializing graphdriver: "/var/lib/docker" contains several valid graphdrivers: aufs, devicemapper; Please cleanup or explicitly choose storage driver (-s <DRIVER>)

解决方案:移除devicemap文件夹,如 mv /var/lib/docker/devicemapper/ .

make build出错一

Step 6 : RUN apt-get update && apt-get install -y apparmor apt-utils aufs-tools automake bash-completion binutils-mingw-w64 bsdmainutils btrfs-tools build-essential clang createrepo curl dpkg-sig gcc-mingw-w64 git iptables jq libapparmor-dev libcap-dev libltdl-dev libsqlite3-dev libsystemd-journal-dev libtool mercurial net-tools pkg-config python-dev python-mock python-pip python-websocket ubuntu-zfs xfsprogs libzfs-dev tar zip --no-install-recommends && pip install awscli==1.10.15---> Running in 32ad02db3575Get:1 http://ppa.launchpad.net trusty InRelease [15.5 kB]Ign http://httpredir.debian.org jessie InReleaseGet:2 http://httpredir.debian.org jessie-updates InRelease [142 kB]Get:3 http://security.debian.org jessie/updates InRelease [63.1 kB]Get:4 http://httpredir.debian.org jessie Release.gpg [2373 B]Get:5 http://ppa.launchpad.net trusty/main amd64 Packages [5150 B]Get:6 http://httpredir.debian.org jessie-updates/main amd64 Packages [17.6 kB]Get:7 http://httpredir.debian.org jessie Release [148 kB]Get:8 http://httpredir.debian.org jessie/main amd64 Packages [9035 kB]Get:9 http://security.debian.org jessie/updates/main amd64 Packages [232 kB]Fetched 9662 kB in 19s (504 kB/s)W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/main/binary-amd64/Packages Hash Sum mismatchW: Failed to fetch http://security.debian.org/dists/jessie/updates/main/binary-amd64/Packages Hash Sum mismatchE: Some index files failed to download. TheW: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/main/binary-amd64/Packages Hash Sum mismatch

看样子是源的问题哎r(st)q

而且是RUN指令,应该是dockerfile运行容器之后的源错误,so,看下docker/Dockerfile

# ARG APT_MIRROR=httpredir.debian.orgRUN sed -i s/httpredir.debian.org/$APT_MIRROR/g /etc/apt/sources.list

在这里修改了源~从网上重新找个ftp.cn.debian.org,然而,。。。还是错。。。

好吧,那把这两句直接全部注释掉,用163的debian源内容echo到容器里,执行

复制代码 代码如下:
RUN echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib\ndeb http://mirrors.163.com/debian/ jessie-updates main non-free contrib\ndeb http://mirrors.163.com/debian/ jessie-backports main non-free contrib\ndeb-src http://mirrors.163.com/debian/ jessie main non-free contrib\ndeb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib\ndeb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib\ndeb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib\ndeb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib" | tee /etc/apt/sources.list

再执行make build,出现依赖问题,那就用aptitude吧

RUN apt-get update && apt-get install -y aptitudeRUN aptitude install -y \ 

(同时去掉Cno-install-recommends\那一行)

make build出错二

Step 15 : RUN set -x   && export SECCOMP_PATH="$(mktemp -d)"   && curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VERSION}/libseccomp-${SECCOMP_VERSION}.tar.gz"     | tar -xzC "$SECCOMP_PATH" --strip-components=1   && (     cd "$SECCOMP_PATH"     && ./configure --prefix=/usr/local     && make     && make install && ldconfig   )   && rm -rf "$SECCOMP_PATH" ---> Running in 4ad66d28289d+ mktemp -d+ export SECCOMP_PATH=/tmp/tmp.TWPYfciRjC+ curl -fsSL https://github.com/seccomp/libseccomp/releases/download/v2.3.1/libseccomp-2.3.1.tar.gz+ tar -xzC /tmp/tmp.TWPYfciRjC --strip-components=1curl: (56) SSL read: error:00000000:lib(0):func(0):reason(0), errno 104gzip: stdin: unexpected end of filetar: Unexpected EOF in archivetar: Unexpected EOF in archivetar: Error is not recoverable: exiting now

网络问题,网上有说先下载下来再用ADD添加进去,结果发现校园网貌似访问这挺快的,连上vpn再执行就行了。。

make binary 出错

复制代码 代码如下:
ERROR:/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: fork/exec /usr/bin/gcc: cannot allocate memory

内存不足~增大虚拟机内存呗

安装结果

make build

make binary

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。


  • 上一条:
    详解从 0 开始使用 Docker 快速搭建 Hadoop 集群环境
    下一条:
    详解使用Docker容器来源码编译etcd
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • 在docker环境中实现Laravel项目执行定时任务和消息队列流程步骤(0个评论)
    • 在MacBook下laravel项目多php版本docker开发环境配置方案(0个评论)
    • 在docker环境中部署docker部署elk架构流程步骤(1个评论)
    • docker compose跟Dockerfile的区别浅析(0个评论)
    • Ubuntu 22.04系统中安装podman流程步骤(1个评论)
    • 近期文章
    • 智能合约Solidity学习CryptoZombie第三课:组建僵尸军队(高级Solidity理论)(0个评论)
    • 智能合约Solidity学习CryptoZombie第二课:让你的僵尸猎食(0个评论)
    • 智能合约Solidity学习CryptoZombie第一课:生成一只你的僵尸(0个评论)
    • 在go中实现一个常用的先进先出的缓存淘汰算法示例代码(0个评论)
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2017-11
    • 2020-06
    • 2021-05
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-03
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-11
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2024-03
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客