Skip to content

"docker-compose up" crashes when using device_cgroup_rules #8052

Description

@dmm

Description of the issue

When I try to create a service with the "device_cgroup_rules" feature "docker-compose up" fails.
For example, this docker-compose.yml file:

version: '2.4'

services:
  hello:
    image: hello-world
    device_cgroup_rules:
      - 'a 189:*  rwm'

I get a crash when I run docker-compose up.

A docker command with the same cgroup argument works fine:

docker run --rm -it --device-cgroup-rule='a 189:* rwm' hello-world:latest

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.28.0, build unknown
docker-py version: 4.4.1
CPython version: 3.9.1
OpenSSL version: OpenSSL 1.1.1i  8 Dec 2020

Output of docker version

Client:
 Version:           20.10.2
 API version:       1.41
 Go version:        go1.15.6
 Git commit:        2291f610ae
 Built:             Tue Jan 19 17:19:21 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.15.6
  Git commit:       8891c58a43
  Built:            Tue Jan 19 17:18:55 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b.m
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

services:
  hello:
    device_cgroup_rules:
    - a 189:*  rwm
    image: hello-world
version: '2.4'

Steps to reproduce the issue

  1. Run docker-compose up on a compose file with device_cgroup_rules.

Observed result

The service fails to create and an error is output.

Expected result

Compose should create the service container as normal.

Stacktrace / full error message

I get this cli output:

$ docker-compose up
Building with native build. Learn about native build in Compose here: https://docs.docker.com/go/compose-native-build/
Creating network "asdf_default" with the default driver
Creating asdf_hello_1 ...

ERROR: for asdf_hello_1  ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

ERROR: for hello  ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

The docker daemon has the following log output:

an 21 08:40:24 <<hostname>> dockerd[563]: http: panic serving @: runtime error: index out of range [0] with length 0
                                      goroutine 1790 [running]:
                                      net/http.(*conn).serve.func1(0xc000e53400)
                                              net/http/server.go:1801 +0x147
                                      panic(0x5632fe2500a0, 0xc000e62480)
                                              runtime/panic.go:975 +0x47a
                                      github.com/docker/docker/oci.AppendDevicePermissionsFromCgroupRules(0xc00095d6c0, 0x8, 0x8, 0xc0079329c0, 0x1, 0x4, 0x0, 0x0, 0xc001213dc0, 0xc000e09630, ...)
                                              github.com/docker/docker/oci/oci.go:34 +0x665
                                      github.com/docker/docker/daemon.WithDevices.func1(0x5632fe47eb60, 0xc000052038, 0x0, 0x0, 0xc000eea5a0, 0xc000f08f00, 0x0, 0x0)
                                              github.com/docker/docker/daemon/oci_linux.go:916 +0x3d4
                                      github.com/docker/docker/vendor/github.com/containerd/containerd/oci.ApplyOpts(0x5632fe47eb60, 0xc000052038, 0x0, 0x0, 0xc000eea5a0, 0xc000f08f00, 0xc00105fd00, 0x11, 0x20, >
                                              github.com/docker/docker/vendor/github.com/containerd/containerd/oci/spec.go:85 +0x9e
                                      github.com/docker/docker/daemon.(*Daemon).createSpec(0xc00000c1e0, 0xc000e9d900, 0x0, 0x0, 0x1)
                                              github.com/docker/docker/daemon/oci_linux.go:1046 +0x52f
                                      github.com/docker/docker/daemon.(*Daemon).containerStart(0xc00000c1e0, 0xc000e9d900, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0)
                                              github.com/docker/docker/daemon/start.go:153 +0x34d
                                      github.com/docker/docker/daemon.(*Daemon).ContainerStart(0xc00000c1e0, 0xc007b07827, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000c97110, 0x5632fbfb913d)
                                              github.com/docker/docker/daemon/start.go:94 +0x1ca
                                      github.com/docker/docker/api/server/router/container.(*containerRouter).postContainersStart(0xc000458c80, 0x5632fe47ebe0, 0xc001802390, 0x5632fe46ed20, 0xc000bdcd20, 0xc0010>
                                              github.com/docker/docker/api/server/router/container/container_routes.go:210 +0x270
                                      github.com/docker/docker/api/server/middleware.ExperimentalMiddleware.WrapHandler.func1(0x5632fe47ebe0, 0xc001802390, 0x5632fe46ed20, 0xc000bdcd20, 0xc00105f600, 0xc0018022d>
                                              github.com/docker/docker/api/server/middleware/experimental.go:26 +0x17d
                                      github.com/docker/docker/api/server/middleware.VersionMiddleware.WrapHandler.func1(0x5632fe47ebe0, 0xc001802360, 0x5632fe46ed20, 0xc000bdcd20, 0xc00105f600, 0xc0018022d0, 0x>
                                              github.com/docker/docker/api/server/middleware/version.go:62 +0x617
                                      github.com/docker/docker/pkg/authorization.(*Middleware).WrapHandler.func1(0x5632fe47ebe0, 0xc001802360, 0x5632fe46ed20, 0xc000bdcd20, 0xc00105f600, 0xc0018022d0, 0x5632fe47>
                                              github.com/docker/docker/pkg/authorization/middleware.go:59 +0x822
                                      github.com/docker/docker/api/server.(*Server).makeHTTPHandler.func1(0x5632fe46ed20, 0xc000bdcd20, 0xc00105f500)
                                              github.com/docker/docker/api/server/server.go:141 +0x258
                                      net/http.HandlerFunc.ServeHTTP(0xc00113adc0, 0x5632fe46ed20, 0xc000bdcd20, 0xc00105f500)
                                              net/http/server.go:2042 +0x46
                                      github.com/docker/docker/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc000fca480, 0x5632fe46ed20, 0xc000bdcd20, 0xc00105f300)
                                              github.com/docker/docker/vendor/github.com/gorilla/mux/mux.go:210 +0xd3
                                      net/http.serverHandler.ServeHTTP(0xc00025e0e0, 0x5632fe46ed20, 0xc000bdcd20, 0xc00105f300)
                                              net/http/server.go:2843 +0xa5
                                      net/http.(*conn).serve(0xc000e53400, 0x5632fe47eb20, 0xc007933d40)
                                              net/http/server.go:1925 +0x8ad
                                      created by net/http.(*Server).Serve
                                              net/http/server.go:2969 +0x36c

Additional information

I'm on Arch but the problem was also present on different machine running Debian 10.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions