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 = requests.post('http://127.0.0.1:4243/containers/' + containerName + '/start')

print startContainerRequest.status_code    #result: 204

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

print execCreateRequest.status_code     #result: 201

execStartRequest = requests.post('http://127.0.0.1:4243/exec/' + 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.

  • Amazon AWS ECS Docker Port not binding correctly
  • Access KVM VM over the network from a Docker container
  • Auto-restarting Docker container on Google Compute Engine
  • nginx docker instance multiple application
  • Docker does not auto update DNS server details in /etc/resolv.conf
  • Docker-Squash command not working
  • Here are my DOCKER_OPTS from /etc/default/docker:

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

  • Docker error permission denied and where do the images end up after pull?
  • Assetss from wwwroot cannot be found on Docker Image
  • Can't push or pull to/from docker registry on localhost
  • python2 interpreter in Docker does not support remote project creation with PyCharm
  • Creating Persistent Volumes on Apache Mesos using HTTP Endpoint
  • AWS docker set --no-cache flag
  • 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.