docker_remote_api_v1.3.rst 22 KB

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