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

Unable to create volume with 2.5.4 #495

Closed
ceecko opened this issue Nov 9, 2018 · 9 comments
Closed

Unable to create volume with 2.5.4 #495

ceecko opened this issue Nov 9, 2018 · 9 comments

Comments

@ceecko
Copy link

ceecko commented Nov 9, 2018

Starting with version 2.5.0 creating volume fails:

const Docker = require('dockerode')
const docker = new Docker({
  socketPath: '/var/run/docker.sock',
})

docker.createVolume({}, (err, volume) => {
  if(err) {
    console.trace(err);
    return;
  }

  console.log('ok')
})

This returns error Error: (HTTP code 400) unexpected - got EOF while reading request body

Docker version 18.06.1-ce
Works ok with v2.4.3

@apocas
Copy link
Owner

apocas commented Nov 12, 2018

I can't replicate this.
Tried 18.09.0-ce-beta1

@ceecko
Copy link
Author

ceecko commented Mar 25, 2020

Strangely I ran into the same issue again just now.
Running dockerode 2.5.8 or 3.1.0 with Docker 19.03.8 and overlay2 storage engine on CentOS 7 I still get the HTTP 400 error.

This does not happen with dockerode 2.4.x though

@ceecko
Copy link
Author

ceecko commented Mar 13, 2021

Almost exactly a year later :)
@apocas I replicated this with 3.2.1 and node 14.14.0 on a fresh installed system with CentOS 7.

Would you like any debugging data to figure out what's going on?

Error: (HTTP code 400) unexpected - got EOF while reading request body
    at /root/fileserver-pm-src/2021-03-11-15-48-10/node_modules/docker-modem/lib/modem.js:301:17
    at getCause (/root/fileserver-pm-src/2021-03-11-15-48-10/node_modules/docker-modem/lib/modem.js:331:7)
    at Modem.buildPayload (/root/fileserver-pm-src/2021-03-11-15-48-10/node_modules/docker-modem/lib/modem.js:300:5)
    at IncomingMessage.<anonymous> (/root/fileserver-pm-src/2021-03-11-15-48-10/node_modules/docker-modem/lib/modem.js:275:14)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  reason: undefined,
  statusCode: 400,
  json: { message: 'got EOF while reading request body' }
}

@ceecko
Copy link
Author

ceecko commented Mar 13, 2021

And I replicated this with Ubuntu 20.04.1 LTS with kernel 4.19.104-microsoft-standard and docker 20.10.2

@apocas
Copy link
Owner

apocas commented Apr 5, 2021

Weird error. I still can't replicate it.
Do you have any more data? :/

@ceecko
Copy link
Author

ceecko commented Apr 5, 2021

I figured what if the API endpoint requires some data? With data, it actually works. Maybe it is the missing Content-Type header which breaks it?

Not working example without any arguments:

DEBUG=* node test
  modem Sending: {
  path: '/volumes/create',
  method: 'POST',
  headers: {},
  key: undefined,
  cert: undefined,
  ca: undefined,
  socketPath: '/var/run/docker.sock'
} +0ms
  modem Received: {"message":"got EOF while reading request body"}
 +5ms

Working example with {name: 'some-test'}:

DEBUG=* node test.js
  modem Sending: {
  path: '/volumes/create?name=some-test',
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'Content-Length': 20 },
  key: undefined,
  cert: undefined,
  ca: undefined,
  socketPath: '/var/run/docker.sock'
} +0ms
  modem Received: {"CreatedAt":"2021-04-05T16:50:50Z","Driver":"local","Labels":null,"Mountpoint":"/var/lib/docker/volumes/some-test/_data","Name":"some-test","Options":null,"Scope":"local"}
 +7ms
ok

@apocas
Copy link
Owner

apocas commented Apr 5, 2021

Cool, you actually found an old docker-modem bug :D

Yes you are right, headers are missing in that situation.

Culprit: https://github.com/apocas/docker-modem/blob/master/lib/modem.js#L178

Going to check it out.

@apocas apocas added the bug label Apr 5, 2021
@apocas apocas self-assigned this Apr 5, 2021
@ceecko
Copy link
Author

ceecko commented Apr 5, 2021

I'm glad we managed to figure this out :)
Maybe a simple allowEmpty: true here would work? https://github.com/apocas/dockerode/blob/master/lib/docker.js#L1018

@apocas
Copy link
Owner

apocas commented Apr 6, 2021

Yes it works :)
Just pushed an improved test and fix.
It will be published in the next version.

@apocas apocas closed this as completed Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants