docker_remote_api_v1.6.rst 25 KB

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