Hi,
you may also modify the configuration shipped by Flatcar:
Create a /etc/systemd/system/containerd.service.d/10-config-location.conf
drop-in file:
[Service]
ExecStart=
ExecStart=/usr/bin/env PATH=${TORCX_BINDIR}:${PATH}
${TORCX_BINDIR}/containerd --config /etc/containerd/containerd.toml
Then copy /run/torcx/unpack/docker/usr/share/containerd/config.toml to
/etc/containerd/containerd.toml and edit as needed, finally run: sudo
systemctl daemon-reload; sudo systemctl restart containerd
The above should be enough to enable the cri plugin and delete the
socket address line to use the default socket location.
Provisioning custom binaries is also an option but one has to be
careful about the PATH. Here is an example where the PATH is set for
the systemd units, but not for interactive use, meaning manually
running commands is not safe unless export PATH=... is done first.
Maybe I can change the preparation service to set up bind-mounts so
that no PATH modification is needed.
This here replicates the config currently shipped by Flatcar but with
custom binaries.
systemd:
units:
- name: prepare-docker.service
enabled: true
contents: |
[Unit]
Description=Download docker binaries
ConditionPathExists=!/opt/bin/docker
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
RemainAfterExit=true
Restart=on-failure
ExecStartPre=/usr/bin/mkdir -p /opt/bin
ExecStartPre=/usr/bin/curl -sSfL -o /opt/docker.tgz
https://download.docker.com/linux/static/stable/x86_64/docker-19.03.13.tgz
ExecStartPre=/usr/bin/tar -v --extract --file /opt/docker.tgz
--directory /opt/ --no-same-owner
ExecStartPre=/usr/bin/rm /opt/docker.tgz
ExecStartPre=/usr/bin/sh -c "mv /opt/docker/* /opt/bin/"
ExecStart=/usr/bin/rmdir /opt/docker
[Install]
WantedBy=multi-user.target
- name: docker.socket
enabled: true
contents: |
[Unit]
PartOf=docker.service
Description=Docker Socket for the API
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
- name: docker.service
enabled: false
contents: |
[Unit]
Description=Docker Application Container Engine
After=containerd.service docker.socket network-online.target
prepare-docker.service
Wants=network-online.target
Requires=containerd.service docker.socket prepare-docker.service
[Service]
Type=notify
EnvironmentFile=-/run/flannel/flannel_docker_opts.env
Environment=DOCKER_SELINUX=--selinux-enabled=true
# the default is not to use systemd for cgroups because the
delegate issues still
# exists and systemd currently does not support the cgroup
feature set required
# for containers run by docker
Environment=PATH=/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
ExecStart=/opt/bin/dockerd --host=fd://
--containerd=/run/containerd/containerd.sock $DOCKER_SELINUX
$DOCKER_OPTS $DOCKER_CGROUPS $DOCKER_OPT_BIP $DOCKER_OPT_MTU
$DOCKER_OPT_IPMASQ
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# 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
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups
of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
- name: containerd.service
enabled: false
contents: |
[Unit]
Description=containerd container runtime
After=network.target prepare-docker.service
Requires=prepare-docker.service
[Service]
Delegate=yes
Environment=PATH=/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
ExecStart=/opt/bin/containerd --config /etc/containerd/config.toml
KillMode=process
Restart=always
# (lack of) limits from the upstream docker service unit
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
[Install]
WantedBy=multi-user.target
storage:
files:
- path: /etc/containerd/config.toml
filesystem: root
mode: 0644
contents:
inline: |
# persistent data location
root = "/var/lib/containerd"
# runtime state information
state = "/run/docker/libcontainerd/containerd"
# set containerd as a subreaper on linux when it is not
running as PID 1
subreaper = true
# set containerd's OOM score
oom_score = -999
# CRI plugin listens on a TCP port by default
disabled_plugins = ["cri"]
# grpc configuration
[grpc]
address = "/run/containerd/containerd.sock"
# socket uid
uid = 0
# socket gid
gid = 0
[plugins.linux]
# shim binary name/path
shim = "containerd-shim"
# runtime binary name/path
runtime = "runc"
# do not use a shim when starting containers, saves on memory but
# live restore is not supported
no_shim = false
# display shim logs in the containerd daemon's log output
shim_debug = true
Regards,
Kai
> --
> You received this message because you are subscribed to the Google Groups "Flatcar Container Linux User" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
flatcar-linux-u...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/flatcar-linux-user/CACaBj2Z%3DBVRrSuM3PuBee2CHV0jta%2BdTf9ehOOrRtgnJOrDrAg%40mail.gmail.com.