diff --git a/src/dockerproxy.js b/src/dockerproxy.js index f76adf2ea..b03b243d7 100644 --- a/src/dockerproxy.js +++ b/src/dockerproxy.js @@ -104,7 +104,7 @@ async function containersCreate(req, res, next) { // eslint-disable-next-line no-unused-vars function process(req, res, next) { // we have to rebuild the body since we consumed in in the parser - if (Object.keys(req.body).length !== 0) { + if (req.body && Object.keys(req.body).length !== 0) { const plainBody = JSON.stringify(req.body); req.dockerRequest.setHeader('Content-Length', Buffer.byteLength(plainBody)); req.dockerRequest.end(plainBody); diff --git a/src/test/dockerproxy-test.js b/src/test/dockerproxy-test.js index 52f1aaad5..4e2891fe5 100644 --- a/src/test/dockerproxy-test.js +++ b/src/test/dockerproxy-test.js @@ -36,8 +36,8 @@ describe('Dockerproxy', function () { // create a container to test against before(async function () { - if (nock.isActive()) nock.restore(); // required to connect to the docker socket await setup(); + if (nock.isActive()) nock.restore(); // required to connect to the docker socket await syslogServer.start(); await dockerProxy.start();