docker_remote_api_v1.6.rst 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  1. :title: Remote API v1.6
  2. :description: API Documentation for Docker
  3. :keywords: API, Docker, rcli, REST, documentation
  4. :orphan:
  5. ======================
  6. Docker Remote API v1.6
  7. ======================
  8. .. contents:: Table of Contents
  9. 1. Brief introduction
  10. =====================
  11. - The Remote API has replaced rcli
  12. - The daemon listens on ``unix:///var/run/docker.sock``, but you can
  13. :ref:`bind_docker`.
  14. - The API tends to be REST, but for some complex commands, like
  15. ``attach`` or ``pull``, the HTTP connection is hijacked to transport
  16. ``stdout, stdin`` and ``stderr``
  17. 2. Endpoints
  18. ============
  19. 2.1 Containers
  20. --------------
  21. List containers
  22. ***************
  23. .. http:get:: /containers/json
  24. List containers
  25. **Example request**:
  26. .. sourcecode:: http
  27. GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
  28. **Example response**:
  29. .. sourcecode:: http
  30. HTTP/1.1 200 OK
  31. Content-Type: application/json
  32. [
  33. {
  34. "Id": "8dfafdbc3a40",
  35. "Image": "base:latest",
  36. "Command": "echo 1",
  37. "Created": 1367854155,
  38. "Status": "Exit 0",
  39. "Ports":[{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
  40. "SizeRw":12288,
  41. "SizeRootFs":0
  42. },
  43. {
  44. "Id": "9cd87474be90",
  45. "Image": "base:latest",
  46. "Command": "echo 222222",
  47. "Created": 1367854155,
  48. "Status": "Exit 0",
  49. "Ports":[],
  50. "SizeRw":12288,
  51. "SizeRootFs":0
  52. },
  53. {
  54. "Id": "3176a2479c92",
  55. "Image": "base:latest",
  56. "Command": "echo 3333333333333333",
  57. "Created": 1367854154,
  58. "Status": "Exit 0",
  59. "Ports":[],
  60. "SizeRw":12288,
  61. "SizeRootFs":0
  62. },
  63. {
  64. "Id": "4cb07b47f9fb",
  65. "Image": "base:latest",
  66. "Command": "echo 444444444444444444444444444444444",
  67. "Created": 1367854152,
  68. "Status": "Exit 0",
  69. "Ports":[],
  70. "SizeRw":12288,
  71. "SizeRootFs":0
  72. }
  73. ]
  74. :query all: 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default
  75. :query limit: Show ``limit`` last created containers, include non-running ones.
  76. :query since: Show only containers created since Id, include non-running ones.
  77. :query before: Show only containers created before Id, include non-running ones.
  78. :query size: 1/True/true or 0/False/false, Show the containers sizes
  79. :statuscode 200: no error
  80. :statuscode 400: bad parameter
  81. :statuscode 500: server error
  82. Create a container
  83. ******************
  84. .. http:post:: /containers/create
  85. Create a container
  86. **Example request**:
  87. .. sourcecode:: http
  88. POST /containers/create HTTP/1.1
  89. Content-Type: application/json
  90. {
  91. "Hostname":"",
  92. "User":"",
  93. "Memory":0,
  94. "MemorySwap":0,
  95. "AttachStdin":false,
  96. "AttachStdout":true,
  97. "AttachStderr":true,
  98. "PortSpecs":null,
  99. "Privileged": false,
  100. "Tty":false,
  101. "OpenStdin":false,
  102. "StdinOnce":false,
  103. "Env":null,
  104. "Cmd":[
  105. "date"
  106. ],
  107. "Dns":null,
  108. "Image":"base",
  109. "Volumes":{},
  110. "VolumesFrom":"",
  111. "WorkingDir":""
  112. }
  113. **Example response**:
  114. .. sourcecode:: http
  115. HTTP/1.1 201 OK
  116. Content-Type: application/json
  117. {
  118. "Id":"e90e34656806"
  119. "Warnings":[]
  120. }
  121. :jsonparam config: the container's configuration
  122. :statuscode 201: no error
  123. :statuscode 404: no such container
  124. :statuscode 406: impossible to attach (container not running)
  125. :statuscode 500: server error
  126. Inspect a container
  127. *******************
  128. .. http:get:: /containers/(id)/json
  129. Return low-level information on the container ``id``
  130. **Example request**:
  131. .. sourcecode:: http
  132. GET /containers/4fa6e0f0c678/json HTTP/1.1
  133. **Example response**:
  134. .. sourcecode:: http
  135. HTTP/1.1 200 OK
  136. Content-Type: application/json
  137. {
  138. "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
  139. "Created": "2013-05-07T14:51:42.041847+02:00",
  140. "Path": "date",
  141. "Args": [],
  142. "Config": {
  143. "Hostname": "4fa6e0f0c678",
  144. "User": "",
  145. "Memory": 0,
  146. "MemorySwap": 0,
  147. "AttachStdin": false,
  148. "AttachStdout": true,
  149. "AttachStderr": true,
  150. "PortSpecs": null,
  151. "Tty": false,
  152. "OpenStdin": false,
  153. "StdinOnce": false,
  154. "Env": null,
  155. "Cmd": [
  156. "date"
  157. ],
  158. "Dns": null,
  159. "Image": "base",
  160. "Volumes": {},
  161. "VolumesFrom": "",
  162. "WorkingDir":""
  163. },
  164. "State": {
  165. "Running": false,
  166. "Pid": 0,
  167. "ExitCode": 0,
  168. "StartedAt": "2013-05-07T14:51:42.087658+02:01360",
  169. "Ghost": false
  170. },
  171. "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  172. "NetworkSettings": {
  173. "IpAddress": "",
  174. "IpPrefixLen": 0,
  175. "Gateway": "",
  176. "Bridge": "",
  177. "PortMapping": null
  178. },
  179. "SysInitPath": "/home/kitty/go/src/github.com/dotcloud/docker/bin/docker",
  180. "ResolvConfPath": "/etc/resolv.conf",
  181. "Volumes": {}
  182. }
  183. :statuscode 200: no error
  184. :statuscode 404: no such container
  185. :statuscode 500: server error
  186. List processes running inside a container
  187. *****************************************
  188. .. http:get:: /containers/(id)/top
  189. List processes running inside the container ``id``
  190. **Example request**:
  191. .. sourcecode:: http
  192. GET /containers/4fa6e0f0c678/top HTTP/1.1
  193. **Example response**:
  194. .. sourcecode:: http
  195. HTTP/1.1 200 OK
  196. Content-Type: application/json
  197. {
  198. "Titles":[
  199. "USER",
  200. "PID",
  201. "%CPU",
  202. "%MEM",
  203. "VSZ",
  204. "RSS",
  205. "TTY",
  206. "STAT",
  207. "START",
  208. "TIME",
  209. "COMMAND"
  210. ],
  211. "Processes":[
  212. ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
  213. ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
  214. ]
  215. }
  216. :query ps_args: ps arguments to use (eg. aux)
  217. :statuscode 200: no error
  218. :statuscode 404: no such container
  219. :statuscode 500: server error
  220. Inspect changes on a container's filesystem
  221. *******************************************
  222. .. http:get:: /containers/(id)/changes
  223. Inspect changes on container ``id`` 's filesystem
  224. **Example request**:
  225. .. sourcecode:: http
  226. GET /containers/4fa6e0f0c678/changes HTTP/1.1
  227. **Example response**:
  228. .. sourcecode:: http
  229. HTTP/1.1 200 OK
  230. Content-Type: application/json
  231. [
  232. {
  233. "Path":"/dev",
  234. "Kind":0
  235. },
  236. {
  237. "Path":"/dev/kmsg",
  238. "Kind":1
  239. },
  240. {
  241. "Path":"/test",
  242. "Kind":1
  243. }
  244. ]
  245. :statuscode 200: no error
  246. :statuscode 404: no such container
  247. :statuscode 500: server error
  248. Export a container
  249. ******************
  250. .. http:get:: /containers/(id)/export
  251. Export the contents of container ``id``
  252. **Example request**:
  253. .. sourcecode:: http
  254. GET /containers/4fa6e0f0c678/export HTTP/1.1
  255. **Example response**:
  256. .. sourcecode:: http
  257. HTTP/1.1 200 OK
  258. Content-Type: application/octet-stream
  259. {{ STREAM }}
  260. :statuscode 200: no error
  261. :statuscode 404: no such container
  262. :statuscode 500: server error
  263. Start a container
  264. *****************
  265. .. http:post:: /containers/(id)/start
  266. Start the container ``id``
  267. **Example request**:
  268. .. sourcecode:: http
  269. POST /containers/(id)/start HTTP/1.1
  270. Content-Type: application/json
  271. {
  272. "Binds":["/tmp:/tmp"],
  273. "LxcConf":{"lxc.utsname":"docker"}
  274. }
  275. **Example response**:
  276. .. sourcecode:: http
  277. HTTP/1.1 204 No Content
  278. Content-Type: text/plain
  279. :jsonparam hostConfig: the container's host configuration (optional)
  280. :statuscode 204: no error
  281. :statuscode 404: no such container
  282. :statuscode 500: server error
  283. Stop a container
  284. ****************
  285. .. http:post:: /containers/(id)/stop
  286. Stop the container ``id``
  287. **Example request**:
  288. .. sourcecode:: http
  289. POST /containers/e90e34656806/stop?t=5 HTTP/1.1
  290. **Example response**:
  291. .. sourcecode:: http
  292. HTTP/1.1 204 OK
  293. :query t: number of seconds to wait before killing the container
  294. :statuscode 204: no error
  295. :statuscode 404: no such container
  296. :statuscode 500: server error
  297. Restart a container
  298. *******************
  299. .. http:post:: /containers/(id)/restart
  300. Restart the container ``id``
  301. **Example request**:
  302. .. sourcecode:: http
  303. POST /containers/e90e34656806/restart?t=5 HTTP/1.1
  304. **Example response**:
  305. .. sourcecode:: http
  306. HTTP/1.1 204 OK
  307. :query t: number of seconds to wait before killing the container
  308. :statuscode 204: no error
  309. :statuscode 404: no such container
  310. :statuscode 500: server error
  311. Kill a container
  312. ****************
  313. .. http:post:: /containers/(id)/kill
  314. Kill the container ``id``
  315. **Example request**:
  316. .. sourcecode:: http
  317. POST /containers/e90e34656806/kill HTTP/1.1
  318. **Example response**:
  319. .. sourcecode:: http
  320. HTTP/1.1 204 OK
  321. :query signal: Signal to send to the container (integer). When not set, SIGKILL is assumed and the call will waits for the container to exit.
  322. :statuscode 204: no error
  323. :statuscode 404: no such container
  324. :statuscode 500: server error
  325. Attach to a container
  326. *********************
  327. .. http:post:: /containers/(id)/attach
  328. Attach to the container ``id``
  329. **Example request**:
  330. .. sourcecode:: http
  331. POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
  332. **Example response**:
  333. .. sourcecode:: http
  334. HTTP/1.1 200 OK
  335. Content-Type: application/vnd.docker.raw-stream
  336. {{ STREAM }}
  337. :query logs: 1/True/true or 0/False/false, return logs. Default false
  338. :query stream: 1/True/true or 0/False/false, return stream. Default false
  339. :query stdin: 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false
  340. :query stdout: 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false
  341. :query stderr: 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false
  342. :statuscode 200: no error
  343. :statuscode 400: bad parameter
  344. :statuscode 404: no such container
  345. :statuscode 500: server error
  346. **Stream details**:
  347. When using the TTY setting is enabled in
  348. :http:post:`/containers/create`, the stream is the raw data
  349. from the process PTY and client's stdin. When the TTY is
  350. disabled, then the stream is multiplexed to separate stdout
  351. and stderr.
  352. The format is a **Header** and a **Payload** (frame).
  353. **HEADER**
  354. The header will contain the information on which stream write
  355. the stream (stdout or stderr). It also contain the size of
  356. the associated frame encoded on the last 4 bytes (uint32).
  357. It is encoded on the first 8 bytes like this::
  358. header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
  359. ``STREAM_TYPE`` can be:
  360. - 0: stdin (will be writen on stdout)
  361. - 1: stdout
  362. - 2: stderr
  363. ``SIZE1, SIZE2, SIZE3, SIZE4`` are the 4 bytes of the uint32 size encoded as big endian.
  364. **PAYLOAD**
  365. The payload is the raw stream.
  366. **IMPLEMENTATION**
  367. The simplest way to implement the Attach protocol is the following:
  368. 1) Read 8 bytes
  369. 2) chose stdout or stderr depending on the first byte
  370. 3) Extract the frame size from the last 4 byets
  371. 4) Read the extracted size and output it on the correct output
  372. 5) Goto 1)
  373. Wait a container
  374. ****************
  375. .. http:post:: /containers/(id)/wait
  376. Block until container ``id`` stops, then returns the exit code
  377. **Example request**:
  378. .. sourcecode:: http
  379. POST /containers/16253994b7c4/wait HTTP/1.1
  380. **Example response**:
  381. .. sourcecode:: http
  382. HTTP/1.1 200 OK
  383. Content-Type: application/json
  384. {"StatusCode":0}
  385. :statuscode 200: no error
  386. :statuscode 404: no such container
  387. :statuscode 500: server error
  388. Remove a container
  389. *******************
  390. .. http:delete:: /containers/(id)
  391. Remove the container ``id`` from the filesystem
  392. **Example request**:
  393. .. sourcecode:: http
  394. DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  395. **Example response**:
  396. .. sourcecode:: http
  397. HTTP/1.1 204 OK
  398. :query v: 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false
  399. :statuscode 204: no error
  400. :statuscode 400: bad parameter
  401. :statuscode 404: no such container
  402. :statuscode 500: server error
  403. Copy files or folders from a container
  404. **************************************
  405. .. http:post:: /containers/(id)/copy
  406. Copy files or folders of container ``id``
  407. **Example request**:
  408. .. sourcecode:: http
  409. POST /containers/4fa6e0f0c678/copy HTTP/1.1
  410. Content-Type: application/json
  411. {
  412. "Resource":"test.txt"
  413. }
  414. **Example response**:
  415. .. sourcecode:: http
  416. HTTP/1.1 200 OK
  417. Content-Type: application/octet-stream
  418. {{ STREAM }}
  419. :statuscode 200: no error
  420. :statuscode 404: no such container
  421. :statuscode 500: server error
  422. 2.2 Images
  423. ----------
  424. List Images
  425. ***********
  426. .. http:get:: /images/(format)
  427. List images ``format`` could be json or viz (json default)
  428. **Example request**:
  429. .. sourcecode:: http
  430. GET /images/json?all=0 HTTP/1.1
  431. **Example response**:
  432. .. sourcecode:: http
  433. HTTP/1.1 200 OK
  434. Content-Type: application/json
  435. [
  436. {
  437. "Repository":"base",
  438. "Tag":"ubuntu-12.10",
  439. "Id":"b750fe79269d",
  440. "Created":1364102658,
  441. "Size":24653,
  442. "VirtualSize":180116135
  443. },
  444. {
  445. "Repository":"base",
  446. "Tag":"ubuntu-quantal",
  447. "Id":"b750fe79269d",
  448. "Created":1364102658,
  449. "Size":24653,
  450. "VirtualSize":180116135
  451. }
  452. ]
  453. **Example request**:
  454. .. sourcecode:: http
  455. GET /images/viz HTTP/1.1
  456. **Example response**:
  457. .. sourcecode:: http
  458. HTTP/1.1 200 OK
  459. Content-Type: text/plain
  460. digraph docker {
  461. "d82cbacda43a" -> "074be284591f"
  462. "1496068ca813" -> "08306dc45919"
  463. "08306dc45919" -> "0e7893146ac2"
  464. "b750fe79269d" -> "1496068ca813"
  465. base -> "27cf78414709" [style=invis]
  466. "f71189fff3de" -> "9a33b36209ed"
  467. "27cf78414709" -> "b750fe79269d"
  468. "0e7893146ac2" -> "d6434d954665"
  469. "d6434d954665" -> "d82cbacda43a"
  470. base -> "e9aa60c60128" [style=invis]
  471. "074be284591f" -> "f71189fff3de"
  472. "b750fe79269d" [label="b750fe79269d\nbase",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  473. "e9aa60c60128" [label="e9aa60c60128\nbase2",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  474. "9a33b36209ed" [label="9a33b36209ed\ntest",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  475. base [style=invisible]
  476. }
  477. :query all: 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default
  478. :statuscode 200: no error
  479. :statuscode 400: bad parameter
  480. :statuscode 500: server error
  481. Create an image
  482. ***************
  483. .. http:post:: /images/create
  484. Create an image, either by pull it from the registry or by importing it
  485. **Example request**:
  486. .. sourcecode:: http
  487. POST /images/create?fromImage=base HTTP/1.1
  488. **Example response**:
  489. .. sourcecode:: http
  490. HTTP/1.1 200 OK
  491. Content-Type: application/json
  492. {"status":"Pulling..."}
  493. {"status":"Pulling", "progress":"1/? (n/a)"}
  494. {"error":"Invalid..."}
  495. ...
  496. When using this endpoint to pull an image from the registry,
  497. the ``X-Registry-Auth`` header can be used to include a
  498. base64-encoded AuthConfig object.
  499. :query fromImage: name of the image to pull
  500. :query fromSrc: source to import, - means stdin
  501. :query repo: repository
  502. :query tag: tag
  503. :query registry: the registry to pull from
  504. :statuscode 200: no error
  505. :statuscode 500: server error
  506. Insert a file in an image
  507. *************************
  508. .. http:post:: /images/(name)/insert
  509. Insert a file from ``url`` in the image ``name`` at ``path``
  510. **Example request**:
  511. .. sourcecode:: http
  512. POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
  513. **Example response**:
  514. .. sourcecode:: http
  515. HTTP/1.1 200 OK
  516. Content-Type: application/json
  517. {"status":"Inserting..."}
  518. {"status":"Inserting", "progress":"1/? (n/a)"}
  519. {"error":"Invalid..."}
  520. ...
  521. :statuscode 200: no error
  522. :statuscode 500: server error
  523. Inspect an image
  524. ****************
  525. .. http:get:: /images/(name)/json
  526. Return low-level information on the image ``name``
  527. **Example request**:
  528. .. sourcecode:: http
  529. GET /images/base/json HTTP/1.1
  530. **Example response**:
  531. .. sourcecode:: http
  532. HTTP/1.1 200 OK
  533. Content-Type: application/json
  534. {
  535. "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  536. "parent":"27cf784147099545",
  537. "created":"2013-03-23T22:24:18.818426-07:00",
  538. "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  539. "container_config":
  540. {
  541. "Hostname":"",
  542. "User":"",
  543. "Memory":0,
  544. "MemorySwap":0,
  545. "AttachStdin":false,
  546. "AttachStdout":false,
  547. "AttachStderr":false,
  548. "PortSpecs":null,
  549. "Tty":true,
  550. "OpenStdin":true,
  551. "StdinOnce":false,
  552. "Env":null,
  553. "Cmd": ["/bin/bash"]
  554. ,"Dns":null,
  555. "Image":"base",
  556. "Volumes":null,
  557. "VolumesFrom":"",
  558. "WorkingDir":""
  559. },
  560. "Size": 6824592
  561. }
  562. :statuscode 200: no error
  563. :statuscode 404: no such image
  564. :statuscode 500: server error
  565. Get the history of an image
  566. ***************************
  567. .. http:get:: /images/(name)/history
  568. Return the history of the image ``name``
  569. **Example request**:
  570. .. sourcecode:: http
  571. GET /images/base/history HTTP/1.1
  572. **Example response**:
  573. .. sourcecode:: http
  574. HTTP/1.1 200 OK
  575. Content-Type: application/json
  576. [
  577. {
  578. "Id":"b750fe79269d",
  579. "Created":1364102658,
  580. "CreatedBy":"/bin/bash"
  581. },
  582. {
  583. "Id":"27cf78414709",
  584. "Created":1364068391,
  585. "CreatedBy":""
  586. }
  587. ]
  588. :statuscode 200: no error
  589. :statuscode 404: no such image
  590. :statuscode 500: server error
  591. Push an image on the registry
  592. *****************************
  593. .. http:post:: /images/(name)/push
  594. Push the image ``name`` on the registry
  595. **Example request**:
  596. .. sourcecode:: http
  597. POST /images/test/push HTTP/1.1
  598. **Example response**:
  599. .. sourcecode:: http
  600. HTTP/1.1 200 OK
  601. Content-Type: application/json
  602. {"status":"Pushing..."}
  603. {"status":"Pushing", "progress":"1/? (n/a)"}
  604. {"error":"Invalid..."}
  605. ...
  606. The ``X-Registry-Auth`` header can be used to include a
  607. base64-encoded AuthConfig object.
  608. :query registry: the registry you wan to push, optional
  609. :statuscode 200: no error
  610. :statuscode 404: no such image
  611. :statuscode 500: server error
  612. Tag an image into a repository
  613. ******************************
  614. .. http:post:: /images/(name)/tag
  615. Tag the image ``name`` into a repository
  616. **Example request**:
  617. .. sourcecode:: http
  618. POST /images/test/tag?repo=myrepo&force=0 HTTP/1.1
  619. **Example response**:
  620. .. sourcecode:: http
  621. HTTP/1.1 200 OK
  622. :query repo: The repository to tag in
  623. :query force: 1/True/true or 0/False/false, default false
  624. :statuscode 200: no error
  625. :statuscode 400: bad parameter
  626. :statuscode 404: no such image
  627. :statuscode 409: conflict
  628. :statuscode 500: server error
  629. Remove an image
  630. ***************
  631. .. http:delete:: /images/(name)
  632. Remove the image ``name`` from the filesystem
  633. **Example request**:
  634. .. sourcecode:: http
  635. DELETE /images/test HTTP/1.1
  636. **Example response**:
  637. .. sourcecode:: http
  638. HTTP/1.1 200 OK
  639. Content-type: application/json
  640. [
  641. {"Untagged":"3e2f21a89f"},
  642. {"Deleted":"3e2f21a89f"},
  643. {"Deleted":"53b4f83ac9"}
  644. ]
  645. :statuscode 200: no error
  646. :statuscode 404: no such image
  647. :statuscode 409: conflict
  648. :statuscode 500: server error
  649. Search images
  650. *************
  651. .. http:get:: /images/search
  652. Search for an image in the docker index
  653. **Example request**:
  654. .. sourcecode:: http
  655. GET /images/search?term=sshd HTTP/1.1
  656. **Example response**:
  657. .. sourcecode:: http
  658. HTTP/1.1 200 OK
  659. Content-Type: application/json
  660. [
  661. {
  662. "Name":"cespare/sshd",
  663. "Description":""
  664. },
  665. {
  666. "Name":"johnfuller/sshd",
  667. "Description":""
  668. },
  669. {
  670. "Name":"dhrp/mongodb-sshd",
  671. "Description":""
  672. }
  673. ]
  674. :query term: term to search
  675. :statuscode 200: no error
  676. :statuscode 500: server error
  677. 2.3 Misc
  678. --------
  679. Build an image from Dockerfile via stdin
  680. ****************************************
  681. .. http:post:: /build
  682. Build an image from Dockerfile via stdin
  683. **Example request**:
  684. .. sourcecode:: http
  685. POST /build HTTP/1.1
  686. {{ STREAM }}
  687. **Example response**:
  688. .. sourcecode:: http
  689. HTTP/1.1 200 OK
  690. {{ STREAM }}
  691. The stream must be a tar archive compressed with one of the following algorithms:
  692. identity (no compression), gzip, bzip2, xz. The archive must include a file called
  693. `Dockerfile` at its root. It may include any number of other files, which will be
  694. accessible in the build context (See the ADD build command).
  695. The Content-type header should be set to "application/tar".
  696. :query t: repository name (and optionally a tag) to be applied to the resulting image in case of success
  697. :query q: suppress verbose build output
  698. :query nocache: do not use the cache when building the image
  699. :statuscode 200: no error
  700. :statuscode 500: server error
  701. Check auth configuration
  702. ************************
  703. .. http:post:: /auth
  704. Get the default username and email
  705. **Example request**:
  706. .. sourcecode:: http
  707. POST /auth HTTP/1.1
  708. Content-Type: application/json
  709. {
  710. "username":"hannibal",
  711. "password:"xxxx",
  712. "email":"hannibal@a-team.com",
  713. "serveraddress":"https://index.docker.io/v1/"
  714. }
  715. **Example response**:
  716. .. sourcecode:: http
  717. HTTP/1.1 200 OK
  718. :statuscode 200: no error
  719. :statuscode 204: no error
  720. :statuscode 500: server error
  721. Display system-wide information
  722. *******************************
  723. .. http:get:: /info
  724. Display system-wide information
  725. **Example request**:
  726. .. sourcecode:: http
  727. GET /info HTTP/1.1
  728. **Example response**:
  729. .. sourcecode:: http
  730. HTTP/1.1 200 OK
  731. Content-Type: application/json
  732. {
  733. "Containers":11,
  734. "Images":16,
  735. "Debug":false,
  736. "NFd": 11,
  737. "NGoroutines":21,
  738. "MemoryLimit":true,
  739. "SwapLimit":false,
  740. "IPv4Forwarding":true
  741. }
  742. :statuscode 200: no error
  743. :statuscode 500: server error
  744. Show the docker version information
  745. ***********************************
  746. .. http:get:: /version
  747. Show the docker version information
  748. **Example request**:
  749. .. sourcecode:: http
  750. GET /version HTTP/1.1
  751. **Example response**:
  752. .. sourcecode:: http
  753. HTTP/1.1 200 OK
  754. Content-Type: application/json
  755. {
  756. "Version":"0.2.2",
  757. "GitCommit":"5a2a5cc+CHANGES",
  758. "GoVersion":"go1.0.3"
  759. }
  760. :statuscode 200: no error
  761. :statuscode 500: server error
  762. Create a new image from a container's changes
  763. *********************************************
  764. .. http:post:: /commit
  765. Create a new image from a container's changes
  766. **Example request**:
  767. .. sourcecode:: http
  768. POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
  769. **Example response**:
  770. .. sourcecode:: http
  771. HTTP/1.1 201 OK
  772. Content-Type: application/vnd.docker.raw-stream
  773. {"Id":"596069db4bf5"}
  774. :query container: source container
  775. :query repo: repository
  776. :query tag: tag
  777. :query m: commit message
  778. :query author: author (eg. "John Hannibal Smith <hannibal@a-team.com>")
  779. :query run: config automatically applied when the image is run. (ex: {"Cmd": ["cat", "/world"], "PortSpecs":["22"]})
  780. :statuscode 201: no error
  781. :statuscode 404: no such container
  782. :statuscode 500: server error
  783. Monitor Docker's events
  784. ***********************
  785. .. http:get:: /events
  786. Get events from docker, either in real time via streaming, or via polling (using `since`)
  787. **Example request**:
  788. .. sourcecode:: http
  789. POST /events?since=1374067924
  790. **Example response**:
  791. .. sourcecode:: http
  792. HTTP/1.1 200 OK
  793. Content-Type: application/json
  794. {"status":"create","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
  795. {"status":"start","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
  796. {"status":"stop","id":"dfdf82bd3881","from":"base:latest","time":1374067966}
  797. {"status":"destroy","id":"dfdf82bd3881","from":"base:latest","time":1374067970}
  798. :query since: timestamp used for polling
  799. :statuscode 200: no error
  800. :statuscode 500: server error
  801. 3. Going further
  802. ================
  803. 3.1 Inside 'docker run'
  804. -----------------------
  805. Here are the steps of 'docker run' :
  806. * Create the container
  807. * If the status code is 404, it means the image doesn't exists:
  808. * Try to pull it
  809. * Then retry to create the container
  810. * Start the container
  811. * If you are not in detached mode:
  812. * Attach to the container, using logs=1 (to have stdout and stderr from the container's start) and stream=1
  813. * If in detached mode or only stdin is attached:
  814. * Display the container's id
  815. 3.2 Hijacking
  816. -------------
  817. In this version of the API, /attach, uses hijacking to transport stdin, stdout and stderr on the same socket. This might change in the future.
  818. 3.3 CORS Requests
  819. -----------------
  820. To enable cross origin requests to the remote api add the flag "-api-enable-cors" when running docker in daemon mode.
  821. .. code-block:: bash
  822. docker -d -H="192.168.1.9:4243" -api-enable-cors