docker_remote_api_v1.4.rst 23 KB

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