docker_remote_api_v1.6.rst 26 KB

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