Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker commit REST API error: {"message":"invalid JSON: got EOF while reading request body"} #45543

Closed
valenbb opened this issue May 16, 2023 · 1 comment · Fixed by #45550
Closed
Labels
kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. kind/regression status/confirmed version/23.0

Comments

@valenbb
Copy link

valenbb commented May 16, 2023

Description

Issue:
After Latest version of docker (23.0.6, build ef23cbc) fails to commit a container when using HTTP REST API.

CentOS 7 and fully patched
Docker version 20.10.24, build 297e128

Using sample documentation provided by Docker to commit a container via HTTP REST API:
https://docs.docker.com/engine/api/sdk/examples/#commit-a-container

curl --unix-socket /var/run/docker.sock -X POST "http://localhost/commit?container=2211ef44b&repo=helloworld:1"
{"Id":"sha256:66d20a926be6267867b0060ddefb2dc50cc4fc6bf3fce53354867239095b80e6"}

Upgrade to latest docker-ce engine: Docker version 23.0.6, build ef23cbc

Repeat test:
curl --unix-socket /var/run/docker.sock -X POST "http://localhost/commit?container=2211ef44b&repo=helloworld:2"
{"message":"invalid JSON: got EOF while reading request body"}

Downgrade docker-ce: yum downgrade 3:docker-ce-20.10.24-3.el7.x86_64

Interestingly version still shows previous:
[root@docker-centos ~]# docker -v
Docker version 23.0.6, build ef23cbc

Repeat test again:
curl --unix-socket /var/run/docker.sock -X POST "http://localhost/commit?container=2211ef44b&repo=helloworld:2"
{"Id":"sha256:d945f4cff496ba4c5851a153050e196c470cc8524ae7c52e0370ae0d0557bde3"}

This is also happening in my production environment using RHEL8 and Rocky Linux 8.

Not sure what has changed. If I need to make changes on my end, could someone point me to the proper documentation?

Thanks,
valenbb

Reproduce

  1. Install docker-ce 20.10.24 per documentation
  2. Perform docker commit using REST API using documentation: https://docs.docker.com/engine/api/sdk/examples/#commit-a-container
  3. Upgrade to latest docker-ce release
  4. Repeat step Whiteouts in layers #2

Expected behavior

curl --unix-socket /var/run/docker.sock -X POST "http://localhost/commit?container=2211ef44b&repo=helloworld:2" should produce an output as below:
{"Id":"sha256:d945f4cff496ba4c5851a153050e196c470cc8524ae7c52e0370ae0d0557bde3"}

docker version

Client: Docker Engine - Community
 Version:           23.0.6
 API version:       1.41 (downgraded from 1.42)
 Go version:        go1.19.9
 Git commit:        ef23cbc
 Built:             Fri May  5 21:21:29 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          20.10.24
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.19.7
  Git commit:       5d6db84
  Built:            Tue Apr  4 18:21:02 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.17.3
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 3
 Server Version: 20.10.24
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version: v1.1.7-0-g860f061
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-1160.90.1.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.7GiB
 Name: docker-centos
 ID: BWAW:2MDW:W3FA:JYOA:IAGR:WPBT:G7JI:QXIM:GKLH:7KXA:BODK:CJ4G
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

@valenbb valenbb added kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. status/0-triage labels May 16, 2023
@corhere
Copy link
Contributor

corhere commented May 17, 2023

config, _, _, err := s.decoder.DecodeConfig(r.Body)
if err != nil && err != io.EOF { // Do not fail if body is empty.
return err
}

It does look like allowing an empty request body is intended, making this a regression. The offending commit looks to be b6d58d7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. kind/regression status/confirmed version/23.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants