[Service] ExecStartPre=-/sbin/modprobe overlay ExecStart=/usr/bin/containerd Type=notify # 允许 containerd 及其运行时管理它所创建的容器的 cgroups Delegate=yes # 确保在 containerd 被关闭时仅终止 containerd 守护程序,而不终止任何子进程,如填充程序和容器 KillMode=process Restart=always RestartSec=5 # 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=infinity # Comment TasksMax if your systemd version does not supports it.Only systemd 226 and above support this version. TasksMax=infinity OOMScoreAdjust=-999
[Install] WantedBy=multi-user.target
如何查看 Containerd 相关插件及其存目录?
描述:在 containerd 配置文件中,您将找到持久性和运行时存储位置的设置,以及各种 API 的 grpc、调试和指标地址。 containerd 在主机系统上还有两个不同的存储位置, 一个用于持久性数据,另一个用于运行时状态。
# 错误信息 $ ctr -n k8s.io i pull harbor.weiyigeek.top/devops/jenkins-jnlp:3.13.8-alpine INFO[0000] trying next host error="failed to do request: Head \"https://harbor.weiyigeek.top/v2/devops/jenkins-jnlp/manifests/3.13.8-alpine\": x509: certificate signed by unknown authority" host=harbor.weiyigeek.top ctr: failed to resolve reference "harbor.weiyigeek.top/devops/jenkins-jnlp:3.13.8-alpine": failed to do request: Head "https://harbor.weiyigeek.top/v2/devops/jenkins-jnlp/manifests/3.13.8-alpine": x509: certificate signed by unknown authority
# 3.初始化安装以全量包为例,如出现如下命令表示安装成功。 /usr/local/bin$ ./containerd-rootless-setuptool.sh install # + systemctl --user enable containerd.service # Created symlink /home/weiyigeek/.config/systemd/user/default.target.wants/containerd.service → /home/weiyigeek/.config/systemd/user/containerd.service. # [INFO] Installed "containerd.service" successfully. # [INFO] To control "containerd.service", run: `systemctl --user (start|stop|restart) containerd.service` # [INFO] To run "containerd.service" on system startup automatically, run: `sudo loginctl enable-linger weiyigeek` # [INFO] ------------------------------------------------------------------------------------------ # [INFO] Use `nerdctl` to connect to the rootless containerd. # [INFO] You do NOT need to specify $CONTAINERD_ADDRESS explicitly.
# 查看 hello-containerd 容器日志 $ nerdctl logs hello-containerd # Hello from Docker! # This message shows that your installation appears to be working correctly. # ....... # Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ # For more examples and ideas, visit:https://docs.docker.com/get-started/
# 容器查看 $ nerdctl ps -a # CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES # 17cc212e69b2 docker.io/library/hello-world:latest "/hello" 2 minutes ago Exited (0) 2 minutes ago hello-containerd
# 查看创建的nginx容器 $ sudo nerdctl ps # CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES # 98eb2f1d4639 docker.io/library/nginx:alpine "/docker-entrypoint.…" About an hour ago Up 0.0.0.0:80->80/tcp nginx
# 进入nginx容器内部 $ nerdctl exec -it nginx -- sh / # whoami root / # ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000 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 2: eth0@if4: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP link/ether ee:e6:a6:9a:07:48 brd ff:ff:ff:ff:ff:ff inet 10.4.0.2/24 brd 10.4.0.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::ece6:a6ff:fe9a:748/64 scope link valid_lft forever preferred_lft forever
# Management commands: apparmor Manage AppArmor profiles builder Manage builds container Manage containers image Manage images ipfs Distributing images on IPFS namespace Manage containerd namespaces network Manage networks system Manage containerd volume Manage volumes Commands: build Build an image from a Dockerfile. Needs buildkitd to be running. commit Create a new image from a container changes completion Generate the autocompletion script for the specified shell compose Compose cp Copy files/folders between a running container and the local filesystem. create Create a new container. Optionally specify "ipfs://" or "ipns://" scheme to pull image from IPFS. events Get real time events from the server exec Run a commandin a running container help Help about any command history Show the history of an image images List images info Display system-wide information inspect Return low-level information on objects. kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container. Currently, only containers created with `nerdctl run -d` are supported. pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image from a registry. Optionally specify "ipfs://" or "ipns://" scheme to pull image from IPFS. push Push an image or a repository to a registry. Optionally specify "ipfs://" or "ipns://" scheme to push image to IPFS. restart Restart one or more running containers rm Remove one or more containers rmi Remove one or more images run Run a commandin a new container. Optionally specify "ipfs://" or "ipns://" scheme to pull image from IPFS. save Save one or more images to a tar archive (streamed to STDOUT by default) start Start one or more running containers stats Display a live stream of container(s) resource usage statistics. stop Stop one or more running containers tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top Display the running processes of a container unpause Unpause all processes within one or more containers update Update one or more running containers version Show the nerdctl version information wait Block until one or more containers stop, thenprint their exit codes.
# Flags: -H, --H string Alias of --address (default "/run/containerd/containerd.sock") -a, --a string Alias of --address (default "/run/containerd/containerd.sock") --address string containerd address, optionally with "unix://" prefix [$CONTAINERD_ADDRESS] (default "/run/containerd/containerd.sock") --cgroup-manager string Cgroup manager to use ("cgroupfs"|"systemd") (default "none") --cni-netconfpath string cni config directory [$NETCONFPATH] (default "/home/weiyigeek/.config/cni/net.d") --cni-path string cni plugins binary directory [$CNI_PATH] (default "/usr/local/libexec/cni") --data-root string Root directory of persistent nerdctl state (managed by nerdctl, not by containerd) (default "/home/weiyigeek/.local/share/nerdctl") --debug debug mode --debug-full debug mode (with full output) -h, --helphelpfor nerdctl --host string Alias of --address (default "/run/containerd/containerd.sock") --hosts-dir strings A directory that contains <HOST:PORT>/hosts.toml (containerd style) or <HOST:PORT>/{ca.cert, cert.pem, key.pem} (docker style) (default [/home/weiyigeek/.config/containerd/certs.d,/home/weiyigeek/.config/docker/certs.d]) --insecure-registry skips verifying HTTPS certs, and allows falling back to plain HTTP -n, --n string Alias of --namespace (default "default") , 支持名称空间。 --namespace string containerd namespace, such as "moby"for Docker, "k8s.io"for Kubernetes [$CONTAINERD_NAMESPACE] (default "default") --snapshotter string containerd snapshotter [$CONTAINERD_SNAPSHOTTER] (default "overlayfs") --storage-driver string Alias of --snapshotter (default "overlayfs") -v, --version version for nerdctl
nerdctl 使用示例
仓库认证
1 2 3 4 5 6 7 8
$ nerdctl login -u weiyigeek index.docker.io # Enter Password: # WARNING: Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See # https://docs.docker.com/engine/reference/commandline/login/#credentials-store # Login Succeeded
$ nerdctl logout # Removing login credentials for https://index.docker.io/v1/
/usr/local/bin$ containerd-rootless-setuptool.sh install-stargz [INFO] Creating "/home/weiyigeek/.config/systemd/user/stargz-snapshotter.service" [INFO] Starting systemd unit "stargz-snapshotter.service" + systemctl --user start stargz-snapshotter.service + sleep 3 + systemctl --user --no-pager --full status stargz-snapshotter.service ........... [INFO] Installed "stargz-snapshotter.service" successfully. [INFO] To control "stargz-snapshotter.service", run: `systemctl --user (start|stop|restart) stargz-snapshotter.service` [INFO] Add the following lines to "/home/weiyigeek/.config/containerd/config.toml" manually, and then run `systemctl --user restart containerd.service`: ### BEGIN ### [proxy_plugins] [proxy_plugins."stargz"] type = "snapshot" address = "/run/user/1000/containerd-stargz-grpc/containerd-stargz-grpc.sock" ### END ### [INFO] Set `export CONTAINERD_SNAPSHOTTER="stargz"` to use the stargz snapshotter.
$ nerdctl ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5e854a58087a docker.io/library/redis:6.2.6-alpine3.15 "docker-entrypoint.s…" 42 seconds ago Up 0.0.0.0:6379->6379/tcp redis-server
方式1.请访问本博主的B站【WeiyiGeek】首页关注UP主, 将自动随机获取解锁验证码。
Method 2.Please visit 【My Twitter】. There is an article verification code in the homepage.
方式3.扫一扫下方二维码,关注本站官方公众号
回复:验证码
将获取解锁(有效期7天)本站所有技术文章哟!