Error 500 when running exec start with Docker Remote API

I am using Docker Remote Api and python requests v2.2.1 to run an exec statement. This is the code I’m using:

import requests
import json

containerName = 'my_container_name'
startContainerRequest ='' + containerName + '/start')

print startContainerRequest.status_code    #result: 204

payload = {'Cmd':["date"]}
headers = {'Content-type': 'application/json'}
execCreateRequest ='' + containerName + '/exec', data=json.dumps(payload), headers=headers)

print execCreateRequest.status_code     #result: 201

execStartRequest ='' + execCreateRequest.json()['Id'] + '/start', headers=headers)

print execStartRequest.status_code      #result: 500
print execStartRequest.text             #EOF

The last REST request fails. Exec inspect works with the same id, so the id isn’t the problem. Using a different command than date in the payload fails as well. I tried with different containers, but got the same results.
Running docker exec my_container_name date from the terminal works.

  • Difference between Docker ENTRYPOINT and Kubernetes container spec COMMAND?
  • how to build and run android apk on emulator using dockerfile
  • Getting cron to run on php:7-fpm image [closed]
  • What benefits does Docker Compose have over Docker Swarm and Docker Stack?
  • Add xserver into Docker container (the host is headless)
  • Creating a running Postgres service inside a docker container
  • Here are my DOCKER_OPTS from /etc/default/docker:

    DOCKER_OPTS="--dns *privateDNS* --dns -H tcp:// -H unix:///var/run/docker.sock"

  • How do I make a comment in a Dockerfile?
  • Permission Denied for SO_DEBUG socket option inside docker
  • docker container started in Detached mode stopped after process execution
  • What's Better for Many Containers: a Large Custom Base Image or Several Small Custom Images?
  • Build a docker image from vagrant
  • Ionic project built with docker do not load static files
  • One Solution collect form web for “Error 500 when running exec start with Docker Remote API”

    Add a JSON body to the Exec start POST request

    POST /exec/e90e34656806/start HTTP/1.1
    Content-Type: application/json
     "Detach": false,
     "Tty": false
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.