1

I try to control a Docker server via the Docker remote API.

Commands like

/containers/json?all=1

or

/containers/15999301b96f/stats

are working perfectly fine. But as soon as I try to start, stop or restart a container with

/containers/15999301b96f/start
/containers/15999301b96f/stop
/containers/15999301b96f/restart

I get a 404 error with the message {"message":"page not found"}.

I'm using docker 1.12.1 and API 1.24.

Thank you in advance!

Philipp Brucker
  • 299
  • 1
  • 4
  • 11
  • 1
    Are you sending a GET or a POST request? [It should be POST](https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/start-a-container) – jannis Nov 23 '16 at 09:02
  • It looks like this was the problem. Is was sending a GET request. Thank you very much! – Philipp Brucker Nov 23 '16 at 09:08
  • Glad I could help. I added this as an answer - you can accept it. Thanks! – jannis Nov 23 '16 at 09:13

2 Answers2

4

For the /containers/(id or name)/[start|stop|restart] endpoints you need to send POST requests instead of GET.

Reference:

jannis
  • 4,843
  • 1
  • 23
  • 53
1

From this guide, you will use GET request with

GET /containers/(id or name)/stats

But here, to start or stop, you will use POST request.

POST /containers/(id or name)/start
POST /containers/(id or name)/stop
Tuan
  • 2,303
  • 2
  • 25
  • 37