docker_remote_api_v1.4.rst 23 KB

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