Unable to `RUN mv` when building any image. All mv is "subdirectory of itself"

I am running Ubuntu 22.04 and docker 24.0.5.

Summary

Given the following trivial Docker file:

FROM ubuntu:22.04

# this works fine
RUN touch /tmp/lol.txt
RUN cp /tmp/lol.txt /tmp/lol2.txt
# this fails!
RUN mv /tmp/lol.txt /tmp/what.txt

I try to build the image using:

docker build --no-cache --progress=plain -f Dockerfile.min -t local/min_fail .

I get the error:

#7 [4/4] RUN mv /tmp/lol.txt /tmp/what.txt
#7 0.359 mv: cannot move '/tmp/lol.txt' to a subdirectory of itself, '/tmp/what.txt'
#7 ERROR: process "/bin/sh -c mv /tmp/lol.txt /tmp/what.txt" did not complete successfully: exit code: 1
------
 > [4/4] RUN mv /tmp/lol.txt /tmp/what.txt:
0.359 mv: cannot move '/tmp/lol.txt' to a subdirectory of itself, '/tmp/what.txt'
------
Dockerfile.min:7
--------------------
   5 |     RUN cp /tmp/lol.txt /tmp/lol2.txt
   6 |     # this fails!
   7 | >>> RUN mv /tmp/lol.txt /tmp/what.txt
   8 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c mv /tmp/lol.txt /tmp/what.txt" did not complete successfully: exit code: 1

Is there something wrong with my host/builder operating system install? I installed following the instructions for Ubuntu on the official website.

Docker info

Client: Docker Engine - Community
 Version:    24.0.5
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.20.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
...
 Server Version: 24.0.5
 Storage Driver: overlay2
  Backing Filesystem: zfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: 

Debugging

This also happens if I change the root image from Ubuntu to Fedora, so I don’t think the problem is the base image:

FROM fedora:38

# this works fine
RUN touch /tmp/lol.txt
RUN cp /tmp/lol.txt /tmp/lol2.txt
# this still fails!
RUN mv /tmp/lol.txt /tmp/what.txt

The error also occurs if I set DOCKER_BUILDKIT=0.

I am able to run the mv command if I open a shell inside of a Docker image.

According to the documentation overlay2 Storage driver supports only ext4 and xfs as backing filesystem. zfs supports only zfs as backing filesystem.

Quote:

Storage driver Supported backing filesystems
overlay2 xfs with ftype=1, ext4
fuse-overlayfs any filesystem
devicemapper direct-lvm
btrfs btrfs
zfs zfs
vfs any filesystem

I’m surprised though that you could install it this way and Docker started. Have you checked the system logs to look for error messages or some warnings mentioning an incompatible storage driver?

journalctl -e -u docker

Solve the problem by switching to ZFS

As advised, I switched to the zfs driver by half-following the instructions in the docs.

Backup & delete /var/lib/docker:

sudo cp -au /var/lib/docker /var/lib/docker.bk
sudo rm -rf /var/lib/docker/*

Configure docker to use zfs by adding to /etc/docker/daemon.json:

{
  "storage-driver": "zfs"
}

Reboot my computer (probably could have restarted the docker daemon instead) and now docker build works!

No errors when using OverlayFS

No error messages on boot.

Aug 26 08:55:17 flatsky systemd[1]: Starting Docker Application Container Engine...
Aug 26 08:55:17 flatsky dockerd[5208]: time="2023-08-26T08:55:17.133673551-04:00" level=info msg="Starting up"
Aug 26 08:55:17 flatsky dockerd[5208]: time="2023-08-26T08:55:17.135422053-04:00" level=info msg="detected 127.0.0.53 nameserver, assuming systemd-resolved, so using resolv.conf: /run/systemd/resolve/reso>
Aug 26 08:55:22 flatsky dockerd[5208]: time="2023-08-26T08:55:22.245966109-04:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
Aug 26 08:55:22 flatsky dockerd[5208]: time="2023-08-26T08:55:22.256373226-04:00" level=info msg="Loading containers: start."
Aug 26 08:55:22 flatsky dockerd[5208]: time="2023-08-26T08:55:22.704598518-04:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to >
Aug 26 08:55:22 flatsky dockerd[5208]: time="2023-08-26T08:55:22.733618381-04:00" level=info msg="Loading containers: done."
Aug 26 08:55:22 flatsky dockerd[5208]: time="2023-08-26T08:55:22.758408473-04:00" level=info msg="Docker daemon" commit=a61e2b4 graphdriver=overlay2 version=24.0.5
Aug 26 08:55:22 flatsky dockerd[5208]: time="2023-08-26T08:55:22.758751941-04:00" level=info msg="Daemon has completed initialization"
Aug 26 08:55:22 flatsky dockerd[5208]: time="2023-08-26T08:55:22.878648289-04:00" level=info msg="API listen on /run/docker.sock"
Aug 26 08:55:22 flatsky systemd[1]: Started Docker Application Container Engine.
Aug 26 09:00:01 flatsky dockerd[5208]: 2023/08/26 09:00:01 http2: server: error reading preface from client @: read unix /run/docker.sock->@: read: connection reset by peer
Aug 26 09:00:01 flatsky dockerd[5208]: time="2023-08-26T09:00:01.653909086-04:00" level=warning msg="no trace recorder found, skipping"

Should I report a bug somewhere?

Why did Docker choose this invalid configuration on install? Should I report this installation bug somewhere?

If you followed the official guide to install Docker: https://docs.docker.com/engine/install/ubuntu/

and it chose overlay2 as storage driver on zfs by default, you can report it here:

Thank you for you help. I’ve opened an issue as you recommended.