Skip to content

API does not properly check for repository name format when committing a container #13821

@christopherobin

Description

@christopherobin

How to reproduce

First start a container:
docker run --rm -t -i --name foobar ubuntu bash

Then send the following curl to the docker daemon:
curl -XPOST 'localhost:8080/commit?container=foobar&comment=foo&repo=test/foobar@foo:bar'

See the repo name test/foobar@foo:bar which should raise an error as foo:bar is an invalid tag, but instead we get a nice reply from the server:
{"Id":"7f8d4a8f7920c781abc94608f4e489f52152ca1e9524ddcb2def1ab55903b2a6"}

From there things start to break as we can't reference the image by name, only by ID:

$ docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
test/foobar                 <none>              7f8d4a8f7920        16 minutes ago      215.7 MB
$ docker inspect test/foobar
Error: No such image or container: test/foobar
[]
$ docker inspect 7f8d4a8f7920
[{
  /* valid inspect data */
}
]

Trying to remove the image just fails in every cases:

$ docker rmi test/foobar
Error response from daemon: No such image: test/foobar
FATA[0000] Error: failed to remove one or more images   
$ docker rmi 7f8d4a8f7920
Error response from daemon: No such repository: test/foobar
FATA[0000] Error: failed to remove one or more images   

After inspecting /var/lib/docker/repositories-devicemapper:

{
  "Repositories": {
    "test/foobar@foo:bar": {
      "latest": "7f8d4a8f7920c781abc94608f4e489f52152ca1e9524ddcb2def1ab55903b2a6"
    }
  }
}

Docker version

Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 7c8fca2
OS/Arch (server): linux/amd64

Docker info

Containers: 2
Images: 210
Storage Driver: devicemapper
 Pool Name: docker-8:7-8265223-pool
 Pool Blocksize: 65.54 kB
 Backing Filesystem: extfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 6.503 GB
 Data Space Total: 107.4 GB
 Data Space Available: 97.7 GB
 Metadata Space Used: 11.4 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.136 GB
 Udev Sync Supported: true
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.93 (2015-01-30)
Execution Driver: native-0.2
Kernel Version: 4.0.5-1-ARCH
Operating System: Arch Linux
CPUs: 4
Total Memory: 7.716 GiB
Name: crobin-linux
ID: 4IWV:LSNC:DVZH:SZAM:YBYF:H32V:54RB:ICX3:S2V3:TCRM:LHZH:IQMU

uname

Linux crobin-linux 4.0.5-1-ARCH #1 SMP PREEMPT Sat Jun 6 18:37:49 CEST 2015 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions