1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon
Sebastiaan van Stijn e424343b43
Fix conflicting container name producint 400 error instead of 409
Commit ebcb7d6b40 removed string checking
for error messages, in favor of typed errors.

In this change, the status code for conflicting container  names
changed from 409 to 400 (validationError).

This patch add a `nameConflictError`, changing the status code to
409 as it was in older versions.

With this change applied, the correct 409 status is returned:

```bash
$ docker create --name c1 busybox
```

```bash
$ curl --unix-socket /var/run/docker.sock -v -XPOST -H"Content-Type: application/json" -d'{"Image":"busybox"}' http://localhost/containers/create?name=c1
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying /var/run/docker.sock...
* Connected to localhost (/var/run/docker.sock) port 80 (#0)
> POST /containers/create?name=c1 HTTP/1.1
> Host: localhost
> User-Agent: curl/7.52.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 19
>
* upload completely sent off: 19 out of 19 bytes
< HTTP/1.1 409 Conflict
< Api-Version: 1.33
< Content-Type: application/json
< Docker-Experimental: false
< Ostype: linux
< Server: Docker/17.06.0-dev (linux)
< Date: Thu, 28 Sep 2017 15:07:23 GMT
< Content-Length: 229
<
{"message":"Conflict. The container name \"/c1\" is already in use by container \"ed2efdc806c1883954e677eb9ab8cbc7e286c9c5934ef6724fd5d93c56744923\". You have to remove (or rename) that container to be able to reuse that name."}
* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-10-04 20:39:45 +02:00
..
caps
cluster Merge pull request #34990 from pradipd/update_field_name 2017-09-27 20:00:18 +02:00
config
discovery
events Merge pull request #34985 from thaJeztah/remove-use-of-deprecated-filter-functions 2017-09-27 17:34:07 +02:00
exec
graphdriver Merge pull request #34342 from coolljt0725/fallback_to_naive_diff 2017-10-03 06:45:17 -07:00
initlayer
links
listeners
logger
names
network Updating moby to correspond to naming convention used in https://github.com/docker/swarmkit/pull/2385 2017-09-26 22:08:10 +00:00
stats
testdata
apparmor_default.go
apparmor_default_unsupported.go
archive.go
archive_tarcopyoptions.go
archive_tarcopyoptions_unix.go
archive_tarcopyoptions_windows.go
archive_unix.go
archive_windows.go
attach.go
auth.go
bindmount_solaris.go
bindmount_unix.go
build.go
cache.go
changes.go
checkpoint.go
cluster.go
commit.go
configs.go
configs_linux.go
configs_unsupported.go
configs_windows.go
container.go
container_linux.go
container_operations.go
container_operations_solaris.go
container_operations_unix.go
container_operations_windows.go
container_windows.go
create.go
create_unix.go
create_windows.go
daemon.go Updating moby to correspond to naming convention used in https://github.com/docker/swarmkit/pull/2385 2017-09-26 22:08:10 +00:00
daemon_experimental.go
daemon_linux.go
daemon_linux_test.go
daemon_solaris.go
daemon_test.go
daemon_unix.go
daemon_unix_test.go
daemon_unsupported.go
daemon_windows.go Merge pull request #34928 from darrenstahlmsft/HnsRunning 2017-09-27 17:35:08 +02:00
daemon_windows_test.go
debugtrap_unix.go
debugtrap_unsupported.go
debugtrap_windows.go
delete.go
delete_test.go
dependency.go
disk_usage.go
errors.go Fix conflicting container name producint 400 error instead of 409 2017-10-04 20:39:45 +02:00
events.go
events_test.go
exec.go
exec_linux.go
exec_solaris.go
exec_windows.go
export.go
getsize_unix.go
health.go
health_test.go
image.go
image_delete.go
image_exporter.go
image_history.go
image_inspect.go
image_pull.go
image_push.go
image_tag.go
images.go
import.go
info.go
info_unix.go
info_unix_test.go
info_windows.go
inspect.go
inspect_solaris.go
inspect_unix.go
inspect_windows.go
keys.go
keys_unsupported.go
kill.go
links.go
list.go
list_unix.go
list_windows.go
logdrivers_linux.go
logdrivers_windows.go
logs.go
logs_test.go
metrics.go
metrics_unix.go
metrics_unsupported.go
monitor.go
monitor_linux.go
monitor_solaris.go
monitor_windows.go
mounts.go
names.go Fix conflicting container name producint 400 error instead of 409 2017-10-04 20:39:45 +02:00
network.go Fixing panic when sandbox is nil 2017-09-29 09:23:06 -07:00
oci_linux.go
oci_solaris.go
oci_windows.go
pause.go
prune.go
reload.go
reload_test.go
rename.go
resize.go
restart.go
search.go
search_test.go
seccomp_disabled.go
seccomp_linux.go
seccomp_unsupported.go
secrets.go
secrets_linux.go
secrets_unsupported.go
secrets_windows.go
selinux_linux.go
selinux_unsupported.go
start.go
start_unix.go
start_windows.go
stats.go
stats_collector.go
stats_unix.go
stats_windows.go
stop.go
top_unix.go
top_unix_test.go
top_windows.go
trustkey.go
trustkey_test.go
unpause.go
update.go
update_linux.go
update_solaris.go
update_windows.go
volumes.go
volumes_unit_test.go
volumes_unix.go
volumes_unix_test.go
volumes_windows.go
wait.go
workdir.go