今天在树莓派上测试跑docker,同事给的交付物是后台起的docker和containerd,没有配置文件,因为需要修改/etc/docker/daemon.json
这个文件,所以还是需要配置文件以systemctl的方式启动,方便重启。
配置文件如下: containerd
[root@localhost system]# pwd
/usr/lib/systemd/system
[root@localhost system]# cat containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target
[Service]
ExecStartPre=/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd
KillMode=process
Delegate=yes
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
TasksMax=infinity
[Install]
WantedBy=multi-user.targe
启动
systemctl enable containerd
systemctl start containerd
docker
[root@localhost system]# pwd
/usr/lib/systemd/system
[root@localhost system]# cat docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# 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
ExecStart=/usr/local/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
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
重启
systemctl enable docker
systemctl start docker
在重新启动 时候,报错如下:
scheme \"unix\" not registered, fallback to default scheme" module=grpc
Error starting daemon: error while opening volume store metadata database: timeout
网上查了下,是这个问题: https://github.com/moby/moby/issues/22507 https://stackoverflow.com/questions/43537790/docker-fails-to-start-due-to-volume-store-metadata-database-timeout
解决办法:
ps axf | grep docker | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh
然后重启docker
systemctl restart docker
======================================= 另外一个问题 docker logs xxxxxx
standard_init_linux.go:207: exec user process caused "exec format error"
这个很有可能就是image制作的有问题,所以启动的时候起来了又停了,可以看看docker ps -a