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.

  • Docker /vfs folder size
  • Dockerize ASP Classic on IIS
  • Docker Performance Testing
  • Visual Studio Docker Tools how to force a container rebuild from scratch
  • Docker: Cronjob is not working
  • vnc to a docker container in vagrant
  • 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"
    

  • Add User to Docker Container
  • docker-compose with a war via volume fails on digital ocean debian but not other debian distros (my home box, work box as well)
  • How to add docker label after image is made
  • In Docker tomcat container tomcat is not running
  • graphql and serverless offline running in docker
  • Docker Containers - User Data
  • 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.