2

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
  • 1,147
  • 5
  • 17
  • 31
  • I could be wrong, but I don't think the containerd is really designed to be used without docker or kubernetes or something else. I thought it was just the runtime component other things use. – Zoredache Aug 08 '21 at 00:23

1 Answers1

1

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
Jonas
  • 1,147
  • 5
  • 17
  • 31