In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to compile containerd". In daily operation, I believe many people have doubts about how to compile containerd. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to compile containerd". Next, please follow the editor to study!
Compile containerd/runc
Any public cloud vendor buys a virtual machine and binds fip (116.196.115.229)
Log in to vm to install go and set the GOROOT/GOPATH environment variable
[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
Edit the / root/.bash_profile file and sourcePATH=$PATH:/usr/local/go/bin after adding the following settings
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
Compile 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
Compile 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 runs in daemon mode
Prepare the containered.service file
[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 setting Boot self-start
[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.
Prepare the containerd profile
[root@containerd ~] # cat / etc/containerd/config.toml
Subreaper = true
Oom_score =-999
[debug]
Level = "debug"
[metrics]
Address = "127.0.0.1purl 1338"
[plugins.linux]
Runtime = "runc"
Shim_debug = true
Start the containerd service
[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.
Prepare rootfs and spec
Find another machine with the full set of docker installed (local oracle linux vm 10.12.162.67 here) and make the rootfs (bundle) file for the test.
Create a busybox/rootfs directory
[root@localhost] # mkdir-p busybox/rootfs
Pull busybox image
[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
Create docker
[root@localhost] # docker create-- name tempbusybox busybox
85b6e32db75da001669656b452a9a65fc2de7f1a9faac95c5aedf6de1127fa15
Export rootfs and 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
Copy rootfs and spec to containered test node 116.196.115.229
[root@localhost] # scp-r busybox/ root@116.196.115.229:/root
test
[root@containerd busybox] # cd / root/busybox
Use containerd cli (/ usr/local/bin/ctr) to run the container
[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
Login Container Verification
[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: 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 container
[root@containerd busybox] # ctr tasks kill-- signal 9 busybox
[root@containerd busybox] # ctr tasks list
TASK PID STATUS
Busybox 15301 STOPPED
Delete Container
[root@containerd busybox] # ctr container delete busybox
[root@containerd busybox] # ctr container list
CONTAINER IMAGE RUNTIME
At this point, the study of "how to compile containerd" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 291
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.