久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

containerd怎么編譯

197次閱讀
沒有評論

共計 7618 個字符,預(yù)計需要花費 20 分鐘才能閱讀完成。

這篇文章主要介紹“containerd 怎么編譯”,在日常操作中,相信很多人在 containerd 怎么編譯問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”containerd 怎么編譯”的疑惑有所幫助!接下來,請跟著丸趣 TV 小編一起來學(xué)習(xí)吧!

編譯 containerd/runc

任意公有云廠商購買一臺虛擬機,綁 fip(116.196.115.229)

登錄 vm 安裝 go,并設(shè)置 GOROOT/GOPATH 環(huán)境變量
[root@containerd bin]# wget https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz
[root@containerd bin]# tar -xvf go1.12.5.linux-amd64.tar.gz -C /usr/local

[root@containerd bin]# /usr/local/go/bin/go version

go version go1.12.5 linux/amd64
編輯 /root/.bash_profile 文件,添加如下設(shè)置后 sourcePATH=$PATH:/usr/local/go/bin
export PATH

export GOROOT=/usr/local/go/
export GOPATH=/root/go[root@containerd ~]# source .bash_profile

Build the development environment

[root@containerd ~]# go get github.com/containerd/containerd
[root@containerd ~]# wget -c https://github.com/google/protobuf/releases/download/v3.5.0/protoc-3.5.0-linux-x86_64.zip
[root@containerd ~]# unzip protoc-3.5.0-linux-x86_64.zip -d /usr/local
[root@containerd ~]# yum install -y btrfs-progs-devel libseccomp-devel

編譯 runc
[root@containerd ~]# go get github.com/opencontainers/runc[root@containerd containerd]# cd $GOPATH/src/github.com/opencontainers/runc

[root@containerd runc]# make

go build -buildmode=pie  -ldflags -X main.gitCommit= eb4aeed24ffbf8e2d740fafea39d91faa0ee84d0

[root@containerd runc]# make install

install -D -m0755 runc /usr/local/sbin/runc

[root@containerd runc]# ls -rtl /usr/local/sbin

total 11752

-rwxr-xr-x 1 root root 12031832 May 10 17:33 runc

[root@containerd runc]# runc –version

runc version 1.0.0-rc8+dev

commit: eb4aeed24ffbf8e2d740fafea39d91faa0ee84d0

spec: 1.0.1-dev

編譯 containerd
[root@containerd runc]# cd $GOPATH/src/github.com/containerd/containerd
[root@containerd containerd]# make
+ bin/ctr
+ bin/containerd
+ bin/containerd-stress
+ bin/containerd-shim
+ bin/containerd-shim-runc-v1
+ bin/containerd-shim-runc-v2
+ binaries
[root@containerd containerd]# make install
+ install bin/ctr bin/containerd bin/containerd-stress bin/containerd-shim bin/containerd-shim-runc-v1 bin/containerd-shim-runc-v2

[root@containerd containerd]# ls -rtl /usr/local/bin

total 133152

-rwxr-x— 1 root root  4433736 Nov 14  2017 protoc

-rwxr-xr-x 1 root root 29709728 May 10 17:35 ctr

-rwxr-xr-x 1 root root 51831136 May 10 17:35 containerd

-rwxr-xr-x 1 root root 25094688 May 10 17:35 containerd-stress

-rwxr-xr-x 1 root root  7302016 May 10 17:35 containerd-shim

-rwxr-xr-x 1 root root  8980256 May 10 17:35 containerd-shim-runc-v1

-rwxr-xr-x 1 root root  8980320 May 10 17:35 containerd-shim-runc-v2

[root@containerd containerd]# containerd –version
containerd github.com/containerd/containerd v1.2.0-551-g57fbb16 57fbb16234fa6c8a61e5e907a4148ea3b05bce1d

containerd 以 daemon 方式運行

準備 containered.service 文件
[root@containerd ~]# cat /usr/lib/systemd/system/containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd

Delegate=yes
KillMode=process
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=1048576
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity

[Install]
WantedBy=multi-user.target

enable 設(shè)置開機自啟動
[root@containerd system]# systemctl enable containerd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/containerd.service to /usr/lib/systemd/system/containerd.service.

準備 containerd 配置文件

[root@containerd ~]# cat /etc/containerd/config.toml

subreaper = true  

oom_score = -999

[debug]

 level = debug

[metrics]

 address = 127.0.0.1:1338

[plugins.linux]

 runtime = runc

 shim_debug = true

啟動 containerd 服務(wù)
[root@containerd system]# systemctl start containerd.service
[root@containerd system]# systemctl status containerd.service
● containerd.service – containerd container runtime
  Loaded: loaded (/usr/lib/systemd/system/containerd.service; enabled; vendor preset: disabled)
  Active: active (running) since Fri 2019-05-10 17:55:35 CST; 4s ago
  Docs: https://containerd.io
  Process: 18319 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
 Main PID: 18321 (containerd)
  Tasks: 13
  Memory: 25.1M
  CGroup: /system.slice/containerd.service
  └─18321 /usr/local/bin/containerd

May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396003271+08:00 level=error msg= Failed to load cni during init, please check CRI plugin status before … cni config
May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396193437+08:00 level=info msg= loading plugin \ io.containerd.grpc.v1.introspection\ … type=io.containerd.grpc.v1
May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396280636+08:00 level=info msg= Start subscribing containerd event
May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396365663+08:00 level=info msg= Start recovering state
May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396383092+08:00 level=info msg=serving… address=/run/containerd/containerd.sock.ttrpc
May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396415058+08:00 level=info msg=serving… address=/run/containerd/containerd.sock
May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396427216+08:00 level=info msg= containerd successfully booted in 0.003786s
May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396435091+08:00 level=info msg= Start event monitor
May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396459564+08:00 level=info msg= Start snapshots syncer
May 10 17:55:35 containerd containerd[18321]: time= 2019-05-10T17:55:35.396468105+08:00 level=info msg= Start streaming server
Hint: Some lines were ellipsized, use -l to show in full.

準備 rootfs 和 spec

找另外一臺安裝了整套 docker 的機器(此處用本地 oracle linux vm 10.12.162.67),制作測試所需的 rootfs(bundle)文件

創(chuàng)建 busybox/rootfs 目錄
[root@localhost ~]# mkdir -p busybox/rootfs

拉取 busybox 鏡像

[root@localhost ~]# docker pull busybox

Using default tag: latest

latest: Pulling from library/busybox

53071b97a884: Pull complete

Digest: sha256:32f65f5aae307c171fc69ce52be3c8b09675164a610a88efa607449311186378

Status: Downloaded newer image for busybox:latest

創(chuàng)建 docker

[root@localhost ~]# docker create –name tempbusybox busybox

85b6e32db75da001669656b452a9a65fc2de7f1a9faac95c5aedf6de1127fa15

導(dǎo)出 rootfs 和 spec

[root@localhost ~]# docker export tempbusybox | tar -C busybox/rootfs -xf –

[root@localhost ~]# cd busybox/   /usr/bin/docker-runc spec

[root@localhost busybox]# ls

config.json  rootfs

[root@localhost busybox]# ls rootfs/

bin  dev  etc  home  proc  root  sys  tmp  usr  var

將 rootfs 和 spec 拷貝到 containered 測試節(jié)點 116.196.115.229
[root@localhost ~]# scp -r busybox/ root@116.196.115.229:/root

測試 [root@containerd busybox]# cd /root/busybox

利用 containerd cli(/usr/local/bin/ctr)運行容器
[root@containerd busybox]# ctr run -t -d –rootfs rootfs busybox /bin/sh

[root@containerd busybox]# ctr container list

CONTAINER  IMAGE  RUNTIME   

busybox  –  io.containerd.runtime.v1.linux

[root@containerd busybox]# ps -ef |grep container

root  9539  1  0 21:22 ?  00:00:03 /usr/local/bin/containerd

root  15285  9539  0 22:02 ?  00:00:00 containerd-shim -namespace default -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/default/busybox -address /run/containerd/containerd.sock -containerd-binary /usr/local/bin/containerd -debug

登錄容器驗證

[root@containerd busybox]# ctr tasks list

TASK  PID  STATUS   

busybox  15301  RUNNING

[root@containerd busybox]# ctr tasks exec -t  –exec-id 15301 busybox /bin/sh

/ # hostname

containerd

/ # ip a

1: lo: LOOPBACK,UP,LOWER_UP mtu 65536 qdisc noqueue qlen 1

  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

  inet 127.0.0.1/8 scope host lo

  valid_lft forever preferred_lft forever

  inet6 ::1/128 scope host

  valid_lft forever preferred_lft forever

stop 容器
[root@containerd busybox]# ctr tasks kill –signal 9 busybox

[root@containerd busybox]# ctr tasks list

TASK  PID  STATUS   

busybox  15301  STOPPED

刪除容器

[root@containerd busybox]# ctr container delete busybox

[root@containerd busybox]# ctr container list

CONTAINER  IMAGE  RUNTIME

到此,關(guān)于“containerd 怎么編譯”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注丸趣 TV 網(wǎng)站,丸趣 TV 小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-16發(fā)表,共計7618字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 公安县| 大渡口区| 沂源县| 札达县| 景宁| SHOW| 孟村| 穆棱市| 酉阳| 武定县| 渝北区| 修水县| 达日县| 息烽县| 洪洞县| 神农架林区| 马山县| 肃宁县| 黎川县| 志丹县| 三河市| 江西省| 嘉黎县| 雅江县| 丹东市| 泰和县| 荣昌县| 冷水江市| 福贡县| 都匀市| 岑巩县| 禹城市| 珲春市| 新余市| 察哈| 永川市| 大宁县| 新乐市| 介休市| 宕昌县| 来安县|