Docker daemon crash on copy file. Bug in the daemon?

Hello,

I’m writing an application in Go that test code in docker container. I’ve created image ready to test code, so I simply copy files on the container, start it, wait for it to finish, and get the logs. The logic is the following

	defer func() {
		if err != nil {
			StopAndRemove(ctx, cli, ctn)
		}
	}()
	archive, err := createTarArchive(files)
	// FIX: error here
	err = cli.CopyToContainer(ctx, ctn, "/", archive, container.CopyToContainerOptions{})
	startTime := time.Now()
	err = cli.ContainerStart(ctx, ctn, container.StartOptions{})
	statusCh, errCh := cli.ContainerWait(ctx, ctn, container.WaitConditionNotRunning)
	logs, err := cli.ContainerLogs(ctx, ctn, container.LogsOptions{
		ShowStdout: true,
		ShowStderr: false,
		Since:      startTime.Format(time.RFC3339),
	})
	defer logs.Close()
	var logBytes bytes.Buffer
	_, err = io.Copy(&logBytes, logs)

I removed error management, comments and logs from the snippet to keep it short and easily understandable even if you don’t know Go well.
Most of the time there’s no issue.
However, sometimes, the CopyToContainer makes the docker daemon crash shutting down the containers running, like my database and giving me this error error during connect: Put "http://%2Fvar%2Frun%2Fdocker.sock/v1.47/containers/b1a3efe79b70816055ecbce4001a53a07772c3b7568472509b902830a094792e/archive?noOverwriteDirNonDir=true&path=%2F": EOF

Of course I can restart them but it’s not great because it slow down everything and invalidate every container running at this moment.

The problem occurs sometimes, but not always without any difference visible. The problem occurs even with no concurrency in the program, so no race condition possible.

I’m on NixOS with

Client:
 Version:           28.1.1
 API version:       1.49
 Go version:        go1.24.2
 Git commit:        v28.1.1
 Built:             Thu Jan  1 00:00:00 1970
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          28.1.1
  API version:      1.49 (minimum version 1.24)
  Go version:       go1.24.2
  Git commit:       v28.1.1
  Built:            Tue Jan  1 00:00:00 1980
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.0.4
  GitCommit:        refs/tags/v2.0.4
 runc:
  Version:          1.2.6
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:

Is it bug from the docker daemon, or the API, or something else ?

NixOS is not officially supported (doc) and Docker software is not the latest release, which might have bugs fixed.

I didn’t know for NixOS :frowning:
Does it means there’s no way to get help on this problem ?
I updated docker to last version 28.1.1 and I still have the same problem

It just means if there is a problem with Docker on NixOS, but it works well on supported operating systems, a fix for NixOS will not likely to come, unless the NixOS maintainers can do it.

My containerd under Docker CE 28.1.1 is Containerd 1.7.27 and runc is 1.2.5 while you have containerd 2.0.4 and runc 1.2.6 (probably not the problem), so you can try to downgrade containerd. But I don’t know how you got these versions. Even the git commit in the client version is different, so I assume you have a Docker installed from the nix package manager and the NixOS maintainers made their own build, so you could try to contact them. Just for comparison, this is my docker version output

Client: Docker Engine - Community
 Version:           28.1.1
 API version:       1.49
 Go version:        go1.23.8
 Git commit:        4eba377
 Built:             Fri Apr 18 09:52:38 2025
 OS/Arch:           linux/arm64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          28.1.1
  API version:      1.49 (minimum version 1.24)
  Go version:       go1.23.8
  Git commit:       01f442b
  Built:            Fri Apr 18 09:52:38 2025
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.7.27
  GitCommit:        05044ec0a9a75232cad458027ca83437aae3f4da
 runc:
  Version:          1.2.5
  GitCommit:        v1.2.5-0-g59923ef
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

I see, thank you for your answer. I will check that