CI pipeline faild. Docker runner execute "docker image prune -f" Error. [Cannot connect to the Docker daemon at unix:///var/run/docker.sock. ]
When I execute the script as below, I get an error. I have referenced common practices on the web, but still can't solve the problem.
like
- gpasswd -a root docker
- service docker start
- systemctl restart docker
- sudo dockerd
Please refer to the following information:
.gitlab-ci.yml file
variables:
GIT_DEPTH: 1
stages:
- cleanup
cleanup-job:
stage: cleanup
script:
- "docker image prune -f"
tags: [ "lone-deploy" ]
Gitlab runner in Docker config
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "xxxxxxxxxxxxxxx"
url = "http://xx.xxx.xx.XX:XX"
token = "XXXXXXXXXXXXXXXXXXXX"
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
Error log
Executing "step_script" stage of the job script
$ docker image prune -f
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/prune?filters=%7B%22dangling%22%3A%7B%22true%22%3Atrue%7D%7D": dial unix /var/run/docker.sock: connect: permission denied
service docker start
root@e69c89312646:/# service docker start
mkdir: cannot create directory 'cpuset': Read-only file system
systemctl restart docker
root@e69c89312646:/# systemctl restart docker
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
When executing dockerd
root@e69c89312646:/# dockerd
INFO[2022-05-11T06:06:58.466986178Z] Starting up
INFO[2022-05-11T06:06:58.472597716Z] libcontainerd: started new containerd process pid=840
INFO[2022-05-11T06:06:58.472633375Z] parsed scheme: "unix" module=grpc
INFO[2022-05-11T06:06:58.472647477Z] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2022-05-11T06:06:58.472674878Z] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock <nil> 0 <nil>}] <nil> <nil>} module=grpc
INFO[2022-05-11T06:06:58.472687725Z] ClientConn switching balancer to "pick_first" module=grpc
WARN[0000] deprecated version : `1`, please switch to version `2`
INFO[2022-05-11T06:06:58.506465537Z] starting containerd revision=212e8b6fa2f44b9c21b2798135fc6fb7c53efc16 version=1.6.4
INFO[2022-05-11T06:06:58.522238750Z] loading plugin "io.containerd.content.v1.content"... type=io.containerd.content.v1
INFO[2022-05-11T06:06:58.522300346Z] loading plugin "io.containerd.snapshotter.v1.aufs"... type=io.containerd.snapshotter.v1
INFO[2022-05-11T06:06:58.522410503Z] skip loading plugin "io.containerd.snapshotter.v1.aufs"... error="aufs is not supported (modprobe aufs failed: exec: \"modprobe\": executable file not found in $PATH \"\"): skip plugin" type=io.containerd.snapshotter.v1
INFO[2022-05-11T06:06:58.522458218Z] loading plugin "io.containerd.snapshotter.v1.btrfs"... type=io.containerd.snapshotter.v1
INFO[2022-05-11T06:06:58.522580408Z] skip loading plugin "io.containerd.snapshotter.v1.btrfs"... error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs (overlay) must be a btrfs filesystem to be used with the btrfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1
INFO[2022-05-11T06:06:58.522600021Z] loading plugin "io.containerd.snapshotter.v1.devmapper"... type=io.containerd.snapshotter.v1
WARN[2022-05-11T06:06:58.522615779Z] failed to load plugin io.containerd.snapshotter.v1.devmapper error="devmapper not configured"
INFO[2022-05-11T06:06:58.522629321Z] loading plugin "io.containerd.snapshotter.v1.native"... type=io.containerd.snapshotter.v1
INFO[2022-05-11T06:06:58.522656843Z] loading plugin "io.containerd.snapshotter.v1.overlayfs"... type=io.containerd.snapshotter.v1
INFO[2022-05-11T06:06:58.522790933Z] loading plugin "io.containerd.snapshotter.v1.zfs"... type=io.containerd.snapshotter.v1
INFO[2022-05-11T06:06:58.522925238Z] skip loading plugin "io.containerd.snapshotter.v1.zfs"... error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1
INFO[2022-05-11T06:06:58.522945240Z] loading plugin "io.containerd.metadata.v1.bolt"... type=io.containerd.metadata.v1
WARN[2022-05-11T06:06:58.522966325Z] could not use snapshotter devmapper in metadata plugin error="devmapper not configured"
INFO[2022-05-11T06:06:58.522980488Z] metadata content store policy set policy=shared
INFO[2022-05-11T06:06:58.523071754Z] loading plugin "io.containerd.differ.v1.walking"... type=io.containerd.differ.v1
INFO[2022-05-11T06:06:58.523096556Z] loading plugin "io.containerd.event.v1.exchange"... type=io.containerd.event.v1
INFO[2022-05-11T06:06:58.523116869Z] loading plugin "io.containerd.gc.v1.scheduler"... type=io.containerd.gc.v1
INFO[2022-05-11T06:06:58.523144680Z] loading plugin "io.containerd.service.v1.introspection-service"... type=io.containerd.service.v1
INFO[2022-05-11T06:06:58.523162208Z] loading plugin "io.containerd.service.v1.containers-service"... type=io.containerd.service.v1
INFO[2022-05-11T06:06:58.523189732Z] loading plugin "io.containerd.service.v1.content-service"... type=io.containerd.service.v1
INFO[2022-05-11T06:06:58.523205144Z] loading plugin "io.containerd.service.v1.diff-service"... type=io.containerd.service.v1
INFO[2022-05-11T06:06:58.523217831Z] loading plugin "io.containerd.service.v1.images-service"... type=io.containerd.service.v1
INFO[2022-05-11T06:06:58.523233540Z] loading plugin "io.containerd.service.v1.leases-service"... type=io.containerd.service.v1
INFO[2022-05-11T06:06:58.523249345Z] loading plugin "io.containerd.service.v1.namespaces-service"... type=io.containerd.service.v1
INFO[2022-05-11T06:06:58.523264158Z] loading plugin "io.containerd.service.v1.snapshots-service"... type=io.containerd.service.v1
INFO[2022-05-11T06:06:58.523293171Z] loading plugin "io.containerd.runtime.v1.linux"... type=io.containerd.runtime.v1
INFO[2022-05-11T06:06:58.523363136Z] loading plugin "io.containerd.runtime.v2.task"... type=io.containerd.runtime.v2
INFO[2022-05-11T06:06:58.523414010Z] loading plugin "io.containerd.monitor.v1.cgroups"... type=io.containerd.monitor.v1
INFO[2022-05-11T06:06:58.524283416Z] loading plugin "io.containerd.service.v1.tasks-service"... type=io.containerd.service.v1
INFO[2022-05-11T06:06:58.524356275Z] loading plugin "io.containerd.grpc.v1.introspection"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524399827Z] loading plugin "io.containerd.internal.v1.restart"... type=io.containerd.internal.v1
INFO[2022-05-11T06:06:58.524510786Z] loading plugin "io.containerd.grpc.v1.containers"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524531981Z] loading plugin "io.containerd.grpc.v1.content"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524585067Z] loading plugin "io.containerd.grpc.v1.diff"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524603384Z] loading plugin "io.containerd.grpc.v1.events"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524620979Z] loading plugin "io.containerd.grpc.v1.healthcheck"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524634311Z] loading plugin "io.containerd.grpc.v1.images"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524645944Z] loading plugin "io.containerd.grpc.v1.leases"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524660710Z] loading plugin "io.containerd.grpc.v1.namespaces"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524676835Z] loading plugin "io.containerd.internal.v1.opt"... type=io.containerd.internal.v1
INFO[2022-05-11T06:06:58.524721096Z] loading plugin "io.containerd.grpc.v1.snapshots"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524733555Z] loading plugin "io.containerd.grpc.v1.tasks"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524747562Z] loading plugin "io.containerd.grpc.v1.version"... type=io.containerd.grpc.v1
INFO[2022-05-11T06:06:58.524759911Z] loading plugin "io.containerd.tracing.processor.v1.otlp"... type=io.containerd.tracing.processor.v1
INFO[2022-05-11T06:06:58.524777001Z] skip loading plugin "io.containerd.tracing.processor.v1.otlp"... error="no OpenTelemetry endpoint: skip plugin" type=io.containerd.tracing.processor.v1
INFO[2022-05-11T06:06:58.524790438Z] loading plugin "io.containerd.internal.v1.tracing"... type=io.containerd.internal.v1
ERRO[2022-05-11T06:06:58.524806830Z] failed to initialize a tracing processor "otlp" error="no OpenTelemetry endpoint: skip plugin"
INFO[2022-05-11T06:06:58.525069213Z] serving... address=/var/run/docker/containerd/containerd-debug.sock
INFO[2022-05-11T06:06:58.525158321Z] serving... address=/var/run/docker/containerd/containerd.sock.ttrpc
INFO[2022-05-11T06:06:58.525225770Z] serving... address=/var/run/docker/containerd/containerd.sock
INFO[2022-05-11T06:06:58.525246624Z] containerd successfully booted in 0.019400s
INFO[2022-05-11T06:06:58.535971552Z] parsed scheme: "unix" module=grpc
INFO[2022-05-11T06:06:58.536000150Z] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2022-05-11T06:06:58.536015882Z] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock <nil> 0 <nil>}] <nil> <nil>} module=grpc
INFO[2022-05-11T06:06:58.536025727Z] ClientConn switching balancer to "pick_first" module=grpc
INFO[2022-05-11T06:06:58.538102629Z] parsed scheme: "unix" module=grpc
INFO[2022-05-11T06:06:58.538125043Z] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2022-05-11T06:06:58.538147402Z] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock <nil> 0 <nil>}] <nil> <nil>} module=grpc
INFO[2022-05-11T06:06:58.538180272Z] ClientConn switching balancer to "pick_first" module=grpc
ERRO[2022-05-11T06:06:58.539490114Z] failed to mount overlay: operation not permitted storage-driver=overlay2
ERRO[2022-05-11T06:06:58.539537335Z] exec: "fuse-overlayfs": executable file not found in $PATH storage-driver=fuse-overlayfs
ERRO[2022-05-11T06:06:58.539643600Z] AUFS was not found in /proc/filesystems storage-driver=aufs
ERRO[2022-05-11T06:06:58.540063354Z] failed to mount overlay: operation not permitted storage-driver=overlay
WARN[2022-05-11T06:06:58.540296599Z] Unable to setup quota: operation not permitted
INFO[2022-05-11T06:06:58.541477889Z] Loading containers: start.
WARN[2022-05-11T06:06:58.542777700Z] Running iptables --wait -t nat -L -n failed with message: `iptables v1.8.4 (legacy): can't initialize iptables table `nat': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.`, error: exit status 3
INFO[2022-05-11T06:06:58.567574282Z] stopping event stream following graceful shutdown error="<nil>" module=libcontainerd namespace=moby
INFO[2022-05-11T06:06:58.567861346Z] stopping event stream following graceful shutdown error="context canceled" module=libcontainerd namespace=plugins.moby
INFO[2022-05-11T06:06:58.567909956Z] stopping healthcheck following graceful shutdown module=libcontainerd
WARN[2022-05-11T06:06:59.568778211Z] grpc: addrConn.createTransport failed to connect to {unix:///var/run/docker/containerd/containerd.sock <nil> 0 <nil>}. Err :connection error: desc = "transport: Error while dialing dial unix:///var/run/docker/containerd/containerd.sock: timeout". Reconnecting... module=grpc
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.8.4 (legacy): can't initialize iptables table `nat': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
(exit status 3)
Edited by Russ Li
