{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/18066","labels_url":"https://api.github.com/repos/docker/docker/issues/18066/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/18066/comments","events_url":"https://api.github.com/repos/docker/docker/issues/18066/events","html_url":"https://github.com/docker/docker/issues/18066","id":117559833,"number":18066,"title":"cannot start container through docker remote API","user":{"login":"juniwang","id":8814383,"avatar_url":"https://avatars.githubusercontent.com/u/8814383?v=3","gravatar_id":"","url":"https://api.github.com/users/juniwang","html_url":"https://github.com/juniwang","followers_url":"https://api.github.com/users/juniwang/followers","following_url":"https://api.github.com/users/juniwang/following{/other_user}","gists_url":"https://api.github.com/users/juniwang/gists{/gist_id}","starred_url":"https://api.github.com/users/juniwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juniwang/subscriptions","organizations_url":"https://api.github.com/users/juniwang/orgs","repos_url":"https://api.github.com/users/juniwang/repos","events_url":"https://api.github.com/users/juniwang/events{/privacy}","received_events_url":"https://api.github.com/users/juniwang/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/kind/question","name":"kind/question","color":"EBEFC9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-11-18T10:38:05Z","updated_at":"2015-11-24T14:53:05Z","closed_at":"2015-11-24T14:52:00Z","body":"Hi guys, I CANNOT start container through docker remote API but I CAN run the same image from commandline.  The error message from [start container API call](https://docs.docker.com/engine/reference/api/docker_remote_api_v1.18/#start-a-container) is `Cannot start container bc88d3e257252f7fcaf69c0ddc008d7b8d8eee2ba3bcb422112ea873d18f23a1: [8] System error: exec: \"\": executable file not found in $PATH`. I used image [rastasheep/ubuntu-sshd](https://hub.docker.com/r/rastasheep/ubuntu-sshd/) for tests.\r\n\r\nResults of `docker ps -a`:\r\n```\r\nCONTAINER ID        IMAGE                    COMMAND                CREATED              STATUS              PORTS                  NAMES\r\nbc88d3e25725        rastasheep/ubuntu-sshd   \"\"                     About a minute ago   Created                                    38-ubuntu-sshd-3sju8tek\r\n8b33e6649fb8        rastasheep/ubuntu-sshd   \"/usr/sbin/sshd -D\"    50 minutes ago       Up 50 minutes       0.0.0.0:2222->22/tcp   reverent_lumiere\r\nd7f0fea869e6        rastasheep/ubuntu-sshd   \" /usr/sbin/sshd -D\"   About an hour ago    Created                                    34-ubuntu-sshd-ljoy27ht\r\n```\r\n\r\n- `bc88d3e25725` created through [API](https://docs.docker.com/engine/reference/api/docker_remote_api_v1.18/#create-a-container), **cannot start**. `CMD` was set to `[]` while creating\r\n- `8b33e6649fb8` created in command line `docker run -d -it -p 2222:22 rastasheep/ubuntu-sshd`, **work well**\r\n- `d7f0fea869e6` also created via API, **cannot start**. `CMD` was set to `[\"/usr/sbin/sshd\", \"-D\"]` while creating\r\n\r\nAs you can see, `COMMAND` are different. Only the second row runs well which was created from command line `docker run -d -it -p 2222:22 rastasheep/ubuntu-sshd`. While the other two are created through remote API.  The COMMAND of first row is empty. The third row has a extra leading space. Both two fails because of ` [8] System error: exec: \"\": executable file not found in $PATH`.  Neigher API nor comandline works for the same error.\r\n\r\nI used python `requests` to send requests(debug in PyCharm). There are two steps. First a request to create a new container, get the `id` from the response. And second send a request to start the container:\r\n\r\n**The first step to create container:**\r\n```\r\nreq = requests.post(containers_url, data=json.dumps(container_config), headers={'content-type': 'application/json'})\r\n```\r\nThe `containers_url` is `u'http://localhost:4243/containers/create?name=41-ubuntu-sshd-gzu684uj'`\r\n\r\nAnd container_config= ```{'Hostname': u'', 'SecurityOpts': [u''], 'Entrypoint': u'', 'Env': [], 'MacAddress': u'', 'User': u'', u'provider': u'0', 'OpenStdin': True, 'AttachStderr': True, 'AttachStdout': True, 'NetworkDisabled': False, 'WorkingDir': u'', 'StdinOnce': True, 'AttachStdin': False, 'Volumes': {}, 'Tty': True, 'Domainname': u'', 'Image': u'rastasheep/ubuntu-sshd', 'Labels': {}, 'HostConfig': {u'Dns': [], u'Memory': 0, u'DnsSearch': [], u'Privileged': False, u'CpusetCpus': u'', u'CgroupParent': u'', u'RestartPolicy': {u'MaximumRetryCount': 0, u'Name': u''}, u'PublishAllPorts': False, u'ReadonlyRootfs': False, u'CpuShares': 0, u'NetworkMode': u'', u'LxcConf': {}, u'Devices': [], u'VolumesFrom': [], u'Binds': [], u'MemorySwap': 0, u'ExtraHosts': [], u'Ulimits': [], u'CapDrop': [], u'Links': [], u'PortBindings': {u'22/tcp': [{'HostPort': '10022', 'HostIp': ''}]}, u'CapAdd': [], u'LogConfig': {u'Type': u'json-file', u'Config': {}}}, 'ExposedPorts': {u'22/tcp': {}}}```\r\n\r\nA better formatted version of `json.dumps(container_config)`:\r\n```\r\n{\r\n  \"Hostname\":\"\",\r\n  \"SecurityOpts\":[\r\n    \"\"\r\n  ],\r\n  \"Entrypoint\":\"\",\r\n  \"Env\":[\r\n  ],\r\n  \"MacAddress\":\"\",\r\n  \"User\":\"\",\r\n  \"provider\":\"0\",\r\n  \"OpenStdin\":true,\r\n  \"AttachStderr\":true,\r\n  \"AttachStdout\":true,\r\n  \"NetworkDisabled\":false,\r\n  \"WorkingDir\":\"\",\r\n  \"StdinOnce\":true,\r\n  \"AttachStdin\":false,\r\n  \"Volumes\":{\r\n  },\r\n  \"Tty\":true,\r\n  \"Domainname\":\"\",\r\n  \"Image\":\"rastasheep/ubuntu-sshd\",\r\n  \"Labels\":{\r\n  },\r\n  \"HostConfig\":{\r\n    \"Dns\":[\r\n    ],\r\n    \"Memory\":0,\r\n    \"DnsSearch\":[\r\n    ],\r\n    \"Privileged\":false,\r\n    \"CpusetCpus\":\"\",\r\n    \"CgroupParent\":\"\",\r\n    \"RestartPolicy\":{\r\n      \"MaximumRetryCount\":0,\r\n      \"Name\":\"\"\r\n    },\r\n    \"PublishAllPorts\":false,\r\n    \"ReadonlyRootfs\":false,\r\n    \"CpuShares\":0,\r\n    \"NetworkMode\":\"\",\r\n    \"LxcConf\":{\r\n    },\r\n    \"Devices\":[\r\n    ],\r\n    \"VolumesFrom\":[\r\n    ],\r\n    \"Binds\":[\r\n    ],\r\n    \"MemorySwap\":0,\r\n    \"ExtraHosts\":[\r\n    ],\r\n    \"Ulimits\":[\r\n    ],\r\n    \"CapDrop\":[\r\n    ],\r\n    \"Links\":[\r\n    ],\r\n    \"PortBindings\":{\r\n      \"22/tcp\":[\r\n        {\r\n          \"HostPort\":\"10022\",\r\n          \"HostIp\":\"\"\r\n        }\r\n      ]\r\n    },\r\n    \"CapAdd\":[\r\n    ],\r\n    \"LogConfig\":{\r\n      \"Type\":\"json-file\",\r\n      \"Config\":{\r\n      }\r\n    }\r\n  },\r\n  \"ExposedPorts\":{\r\n    \"22/tcp\":{\r\n    }\r\n  }\r\n}\r\n```\r\nThe request succeeds with code `[201]` and content `'{\"Id\":\"8e075f05c8b549c67ec891855d0d4061aa819e4d76b40e8fa85969e064f0e2ce\",\"Warnings\":null}\r\n'`\r\n\r\nCode and parameters for **the second step to start the container**. \r\n```\r\nreq = requests.post(url, headers={'content-type': 'application/json'})\r\n```\r\nthe `url` is `u'http://localhost:4243/containers/8e075f05c8b549c67ec891855d0d4061aa819e4d76b40e8fa85969e064f0e2ce/start'` where the id got from response of the first step varies every time. This time, the response is `<Response [404]>` and content `'Cannot start container 8e075f05c8b549c67ec891855d0d4061aa819e4d76b40e8fa85969e064f0e2ce: [8] System error: exec: \"\": executable file not found in $PATH\r\n'`\r\n\r\nMy docker version:\r\n```\r\nClient:\r\n Version:      1.8.1\r\n API version:  1.20\r\n Go version:   go1.4.2\r\n Git commit:   d12ea79\r\n Built:        Thu Aug 13 02:40:42 UTC 2015\r\n OS/Arch:      linux/amd64\r\n\r\nServer:\r\n Version:      1.8.1\r\n API version:  1.20\r\n Go version:   go1.4.2\r\n Git commit:   d12ea79\r\n Built:        Thu Aug 13 02:40:42 UTC 2015\r\n OS/Arch:      linux/amd64\r\n```\r\n\r\ndocker info:\r\n```\r\nContainers: 2\r\nImages: 13\r\nStorage Driver: aufs\r\n Root Dir: /var/lib/docker/aufs\r\n Backing Filesystem: extfs\r\n Dirs: 17\r\n Dirperm1 Supported: true\r\nExecution Driver: native-0.2\r\nLogging Driver: json-file\r\nKernel Version: 3.19.0-26-generic\r\nOperating System: Ubuntu 15.04\r\nCPUs: 1\r\nTotal Memory: 4.812 GiB\r\nName: junbo\r\nID: TBBN:ZGN4:LAJW:3ZSJ:K5AM:3ARP:KFBE:QCCO:RC2S:5HZT:DDRH:HRKH\r\nWARNING: No swap limit support\r\n```\r\n\r\nuname -a:\r\n```\r\nLinux junbo 3.19.0-26-generic #28-Ubuntu SMP Tue Aug 11 14:16:32 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux\r\n```"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/159291630","html_url":"https://github.com/docker/docker/issues/18066#issuecomment-159291630","issue_url":"https://api.github.com/repos/docker/docker/issues/18066","id":159291630,"user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T14:53:05Z","updated_at":"2015-11-24T14:53:05Z","body":"Yes, behavior was changed such that if `Entrypoint` is changed, `CMD` is cleared."}}