Docker daemon on FreeBSD fails to start: issue with graphdriver and zfs

1.6k views Asked by At

I am on x86 FreeBSD. I followed the instructions here: https://wiki.freebsd.org/Docker.

When I start docker, I get

[root@udoo:dev ]# docker run -it quay.io/skilbjo/router-logs bash
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

So I restart the daemon ...

[root@udoo:dev ]# service docker start && docker -dD
Starting docker...
DEBU[0000] Registering GET, /info
DEBU[0000] Registering GET, /images/search
DEBU[0000] Registering GET, /containers/ps
... etc ....
DEBU[0000] Registering POST, /containers/{name:.*}/pause
DEBU[0000] Registering POST, /containers/{name:.*}/exec
DEBU[0000] Registering POST, /containers/{name:.*}/rename
DEBU[0000] Registering DELETE, /containers/{name:.*}
DEBU[0000] Registering DELETE, /images/{name:.*}
DEBU[0000] Registering OPTIONS,
WARN[0000] Kernel version detection is available only on linux
DEBU[0000] Warning: could not change group /var/run/docker.sock to docker: Group docker not found
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
FATA[0000] Error starting daemon: error initializing graphdriver: Failed to find zfs dataset mounted on '/var/lib/docker' in /proc/mounts

some other helpful info (exactly as the docs describe):

[root@udoo:dev ]# zfs list
NAME           USED  AVAIL  REFER  MOUNTPOINT
zroot         10.6M  3.74G    23K  /zroot
zroot/docker  10.4M  3.74G  10.4M  /usr/docker
[root@udoo:dev ]# zpool list
NAME    SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
zroot  3.88G  10.6M  3.86G         -     0%     0%  1.00x  ONLINE  -
[root@udoo:dev ]# docker version
Client version: 1.7.0-dev
Client API version: 1.19
Go version (client): go1.8.3
Git commit (client): 582db78
OS/Arch (client): freebsd/amd64
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

What's going on here? Why won't the docker daemon load? I found very little while researching "/var/lib/docker in /proc/mounts".

EDIT: Trying @tarun-lalwani's suggestion gets me closer, but not quite started yet...

DEBU[0000] Warning: could not change group /var/run/docker.sock to docker: Group docker not found
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
DEBU[0000] [zfs] zfs get -rHp -t filesystem all zroot/docker2
DEBU[0000] Using graph driver zfs
DEBU[0000] Using default logging driver json-file
DEBU[0000] Creating images graph
DEBU[0000] Restored 0 elements
DEBU[0000] Creating repository list
DEBU[0000] [bridge] init driver
WARN[0000] port allocator - using fallback port range 49153-65535 due to error: open /proc/sys/net/ipv4/ip_local_port_range: no such file or directory
DEBU[0000] [bridge] found ip address: 172.17.42.1/16
FATA[0000] Error starting daemon: unknown exec driver native
1

There are 1 answers

0
Lucas Holt On

There are several pieces here. First, you do need /var/lib/docker mounted on ZFS.

Second, you need to create a docker group in /etc/group.

pw groupadd docker

It also looks like it's trying to hit procfs which is not enabled by default on FreeBSD for several releases. Add this to /etc/fstab

proc            /proc   procfs  rw 0 

You also need to be on a new enough FreeBSD release. As I recall it required 10.x or higher.

The docker project did not want to take upstream patches for FreeBSD support. The effort to support docker kind of fell apart after that. Microsoft even tried to encourage it with some hackathons for docker on FreeBSD. It's recommended not to use docker, especially for production, on FreeBSD. In fact, as of this writing, the docker-freebsd port hasn't been modified since 2018.