大网数据广告活动
服务器运维问答

How to start containerd as a service after yum install?

· 52CE 我爱测

I installed containerd on Amazon Linux 2 using the suggested commands : sudo amazon-linux-extras enable docker sudo yum install -y containerd I added this in the EC2 user data script to run at instance launch time. But, how am I …

问题原文

原帖链接 · Jonas · CC BY-SA 4.0

I installed containerd on Amazon Linux 2 using the suggested commands:

sudo amazon-linux-extras enable docker
sudo yum install -y containerd

I added this in the EC2 user data script to run at instance launch time.

But, how am I supposed to start containerd (a container runtime - similar to docker) as a service? Since I installed through yum there doesn't seem to include a systemd service file. The binary is located on /usr/bin/containerd. Am I supposed to use echo in the boot script to generate a systemd service file or what is a good practice?

已采纳解答

原帖链接 · Jonas · CC BY-SA 4.0

I ended up with adding these lines to the startup script:

cat <<EOF | sudo tee /etc/systemd/system/containerd.service
[Unit]
Description=containerd
Documentation=https://containerd.io

[Service]
Type=notify
ExecStart=/usr/bin/containerd

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl enable containerd
sudo systemctl start containerd

Looks like the containerd service was started:

$ sudo ctr version
Client:
  Version:  1.4.6
  Revision: d71fcd7d8303cbf684402823e425e9dd2e99285d
  Go version: go1.15.12

Server:
  Version:  1.4.6
  Revision: d71fcd7d8303cbf684402823e425e9dd2e99285d
  UUID: 25f1bff3-b72d-45f2-99d2-78c0df126faa

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-08-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。