Skip to content

Commit

Permalink
Fix bug which mistakes 400 error for 500
Browse files Browse the repository at this point in the history
cherry-picked from upstream moby#22762

When users run/create a container without specifying a command, daemon
will return 500 error instead of 400 error.

For example:

Dockerfile:
From debian:jessie
CMD []

docker build -t test .
docker create/run test

Signed-off-by: Wang Xing hzwangxing@corp.netease.com

Signed-off-by: xiekeyang <xiekeyang@huawei.com>
  • Loading branch information
Wang Xing authored and xiekeyang committed Jun 29, 2017
1 parent 09d2c25 commit 9a9bd21
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/server/httputils/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func WriteError(w http.ResponseWriter, err error) {
"cannot find": http.StatusNotFound,
"no such": http.StatusNotFound,
"bad parameter": http.StatusBadRequest,
"no command": http.StatusBadRequest,
"conflict": http.StatusConflict,
"impossible": http.StatusNotAcceptable,
"wrong login/password": http.StatusUnauthorized,
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/api/docker_remote_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ This section lists each version from latest to oldest. Each listing includes a
* `POST /containers/create` now allows specifying `nocopy` for named volumes, which disables automatic copying from the container path to the volume.
* `POST /auth` now returns an `IdentityToken` when supported by a registry.
* `POST /containers/create` with both `Hostname` and `Domainname` fields specified will result in the container's hostname being set to `Hostname`, rather than `Hostname.Domainname`.
* `POST /containers/create` now returns a HTTP 400 "bad parameter" message
if no command is specified (instead of a HTTP 500 "server error")

### v1.22 API changes

Expand Down
1 change: 1 addition & 0 deletions docs/reference/api/docker_remote_api_v1.18.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ Query Parameters:
Status Codes:

- **201** – no error
- **400** – bad parameter
- **404** – no such container
- **406** – impossible to attach (container not running)
- **500** – server error
Expand Down
1 change: 1 addition & 0 deletions docs/reference/api/docker_remote_api_v1.19.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ Query Parameters:
Status Codes:

- **201** – no error
- **400** – bad parameter
- **404** – no such container
- **406** – impossible to attach (container not running)
- **500** – server error
Expand Down
1 change: 1 addition & 0 deletions docs/reference/api/docker_remote_api_v1.20.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ Query Parameters:
Status Codes:

- **201** – no error
- **400** – bad parameter
- **404** – no such container
- **406** – impossible to attach (container not running)
- **500** – server error
Expand Down
1 change: 1 addition & 0 deletions docs/reference/api/docker_remote_api_v1.21.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ Query Parameters:
Status Codes:

- **201** – no error
- **400** – bad parameter
- **404** – no such container
- **406** – impossible to attach (container not running)
- **500** – server error
Expand Down
1 change: 1 addition & 0 deletions docs/reference/api/docker_remote_api_v1.22.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ Query Parameters:
Status Codes:

- **201** – no error
- **400** – bad parameter
- **404** – no such container
- **406** – impossible to attach (container not running)
- **500** – server error
Expand Down
1 change: 1 addition & 0 deletions docs/reference/api/docker_remote_api_v1.23.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ Query Parameters:
Status Codes:

- **201** – no error
- **400** – bad parameter
- **404** – no such container
- **406** – impossible to attach (container not running)
- **500** – server error
Expand Down

0 comments on commit 9a9bd21

Please sign in to comment.