docker_remote_api_v1.6.rst 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  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. :statuscode 204: no error
  319. :statuscode 404: no such container
  320. :statuscode 500: server error
  321. Attach to a container
  322. *********************
  323. .. http:post:: /containers/(id)/attach
  324. Attach to the container ``id``
  325. **Example request**:
  326. .. sourcecode:: http
  327. POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
  328. **Example response**:
  329. .. sourcecode:: http
  330. HTTP/1.1 200 OK
  331. Content-Type: application/vnd.docker.raw-stream
  332. {{ STREAM }}
  333. :query logs: 1/True/true or 0/False/false, return logs. Default false
  334. :query stream: 1/True/true or 0/False/false, return stream. Default false
  335. :query stdin: 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false
  336. :query stdout: 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false
  337. :query stderr: 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false
  338. :statuscode 200: no error
  339. :statuscode 400: bad parameter
  340. :statuscode 404: no such container
  341. :statuscode 500: server error
  342. **Stream details**:
  343. When using the TTY setting is enabled in
  344. :http:post:`/containers/create`, the stream is the raw data
  345. from the process PTY and client's stdin. When the TTY is
  346. disabled, then the stream is multiplexed to separate stdout
  347. and stderr.
  348. The format is a **Header** and a **Payload** (frame).
  349. **HEADER**
  350. The header will contain the information on which stream write
  351. the stream (stdout or stderr). It also contain the size of
  352. the associated frame encoded on the last 4 bytes (uint32).
  353. It is encoded on the first 8 bytes like this::
  354. header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
  355. ``STREAM_TYPE`` can be:
  356. - 0: stdin (will be writen on stdout)
  357. - 1: stdout
  358. - 2: stderr
  359. ``SIZE1, SIZE2, SIZE3, SIZE4`` are the 4 bytes of the uint32 size encoded as big endian.
  360. **PAYLOAD**
  361. The payload is the raw stream.
  362. **IMPLEMENTATION**
  363. The simplest way to implement the Attach protocol is the following:
  364. 1) Read 8 bytes
  365. 2) chose stdout or stderr depending on the first byte
  366. 3) Extract the frame size from the last 4 byets
  367. 4) Read the extracted size and output it on the correct output
  368. 5) Goto 1)
  369. Wait a container
  370. ****************
  371. .. http:post:: /containers/(id)/wait
  372. Block until container ``id`` stops, then returns the exit code
  373. **Example request**:
  374. .. sourcecode:: http
  375. POST /containers/16253994b7c4/wait HTTP/1.1
  376. **Example response**:
  377. .. sourcecode:: http
  378. HTTP/1.1 200 OK
  379. Content-Type: application/json
  380. {"StatusCode":0}
  381. :statuscode 200: no error
  382. :statuscode 404: no such container
  383. :statuscode 500: server error
  384. Remove a container
  385. *******************
  386. .. http:delete:: /containers/(id)
  387. Remove the container ``id`` from the filesystem
  388. **Example request**:
  389. .. sourcecode:: http
  390. DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  391. **Example response**:
  392. .. sourcecode:: http
  393. HTTP/1.1 204 OK
  394. :query v: 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false
  395. :statuscode 204: no error
  396. :statuscode 400: bad parameter
  397. :statuscode 404: no such container
  398. :statuscode 500: server error
  399. Copy files or folders from a container
  400. **************************************
  401. .. http:post:: /containers/(id)/copy
  402. Copy files or folders of container ``id``
  403. **Example request**:
  404. .. sourcecode:: http
  405. POST /containers/4fa6e0f0c678/copy HTTP/1.1
  406. Content-Type: application/json
  407. {
  408. "Resource":"test.txt"
  409. }
  410. **Example response**:
  411. .. sourcecode:: http
  412. HTTP/1.1 200 OK
  413. Content-Type: application/octet-stream
  414. {{ STREAM }}
  415. :statuscode 200: no error
  416. :statuscode 404: no such container
  417. :statuscode 500: server error
  418. 2.2 Images
  419. ----------
  420. List Images
  421. ***********
  422. .. http:get:: /images/(format)
  423. List images ``format`` could be json or viz (json default)
  424. **Example request**:
  425. .. sourcecode:: http
  426. GET /images/json?all=0 HTTP/1.1
  427. **Example response**:
  428. .. sourcecode:: http
  429. HTTP/1.1 200 OK
  430. Content-Type: application/json
  431. [
  432. {
  433. "Repository":"base",
  434. "Tag":"ubuntu-12.10",
  435. "Id":"b750fe79269d",
  436. "Created":1364102658,
  437. "Size":24653,
  438. "VirtualSize":180116135
  439. },
  440. {
  441. "Repository":"base",
  442. "Tag":"ubuntu-quantal",
  443. "Id":"b750fe79269d",
  444. "Created":1364102658,
  445. "Size":24653,
  446. "VirtualSize":180116135
  447. }
  448. ]
  449. **Example request**:
  450. .. sourcecode:: http
  451. GET /images/viz HTTP/1.1
  452. **Example response**:
  453. .. sourcecode:: http
  454. HTTP/1.1 200 OK
  455. Content-Type: text/plain
  456. digraph docker {
  457. "d82cbacda43a" -> "074be284591f"
  458. "1496068ca813" -> "08306dc45919"
  459. "08306dc45919" -> "0e7893146ac2"
  460. "b750fe79269d" -> "1496068ca813"
  461. base -> "27cf78414709" [style=invis]
  462. "f71189fff3de" -> "9a33b36209ed"
  463. "27cf78414709" -> "b750fe79269d"
  464. "0e7893146ac2" -> "d6434d954665"
  465. "d6434d954665" -> "d82cbacda43a"
  466. base -> "e9aa60c60128" [style=invis]
  467. "074be284591f" -> "f71189fff3de"
  468. "b750fe79269d" [label="b750fe79269d\nbase",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  469. "e9aa60c60128" [label="e9aa60c60128\nbase2",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  470. "9a33b36209ed" [label="9a33b36209ed\ntest",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  471. base [style=invisible]
  472. }
  473. :query all: 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default
  474. :statuscode 200: no error
  475. :statuscode 400: bad parameter
  476. :statuscode 500: server error
  477. Create an image
  478. ***************
  479. .. http:post:: /images/create
  480. Create an image, either by pull it from the registry or by importing it
  481. **Example request**:
  482. .. sourcecode:: http
  483. POST /images/create?fromImage=base HTTP/1.1
  484. **Example response**:
  485. .. sourcecode:: http
  486. HTTP/1.1 200 OK
  487. Content-Type: application/json
  488. {"status":"Pulling..."}
  489. {"status":"Pulling", "progress":"1/? (n/a)"}
  490. {"error":"Invalid..."}
  491. ...
  492. When using this endpoint to pull an image from the registry,
  493. the ``X-Registry-Auth`` header can be used to include a
  494. base64-encoded AuthConfig object.
  495. :query fromImage: name of the image to pull
  496. :query fromSrc: source to import, - means stdin
  497. :query repo: repository
  498. :query tag: tag
  499. :query registry: the registry to pull from
  500. :statuscode 200: no error
  501. :statuscode 500: server error
  502. Insert a file in an image
  503. *************************
  504. .. http:post:: /images/(name)/insert
  505. Insert a file from ``url`` in the image ``name`` at ``path``
  506. **Example request**:
  507. .. sourcecode:: http
  508. POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
  509. **Example response**:
  510. .. sourcecode:: http
  511. HTTP/1.1 200 OK
  512. Content-Type: application/json
  513. {"status":"Inserting..."}
  514. {"status":"Inserting", "progress":"1/? (n/a)"}
  515. {"error":"Invalid..."}
  516. ...
  517. :statuscode 200: no error
  518. :statuscode 500: server error
  519. Inspect an image
  520. ****************
  521. .. http:get:: /images/(name)/json
  522. Return low-level information on the image ``name``
  523. **Example request**:
  524. .. sourcecode:: http
  525. GET /images/base/json HTTP/1.1
  526. **Example response**:
  527. .. sourcecode:: http
  528. HTTP/1.1 200 OK
  529. Content-Type: application/json
  530. {
  531. "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  532. "parent":"27cf784147099545",
  533. "created":"2013-03-23T22:24:18.818426-07:00",
  534. "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  535. "container_config":
  536. {
  537. "Hostname":"",
  538. "User":"",
  539. "Memory":0,
  540. "MemorySwap":0,
  541. "AttachStdin":false,
  542. "AttachStdout":false,
  543. "AttachStderr":false,
  544. "PortSpecs":null,
  545. "Tty":true,
  546. "OpenStdin":true,
  547. "StdinOnce":false,
  548. "Env":null,
  549. "Cmd": ["/bin/bash"]
  550. ,"Dns":null,
  551. "Image":"base",
  552. "Volumes":null,
  553. "VolumesFrom":"",
  554. "WorkingDir":""
  555. },
  556. "Size": 6824592
  557. }
  558. :statuscode 200: no error
  559. :statuscode 404: no such image
  560. :statuscode 500: server error
  561. Get the history of an image
  562. ***************************
  563. .. http:get:: /images/(name)/history
  564. Return the history of the image ``name``
  565. **Example request**:
  566. .. sourcecode:: http
  567. GET /images/base/history HTTP/1.1
  568. **Example response**:
  569. .. sourcecode:: http
  570. HTTP/1.1 200 OK
  571. Content-Type: application/json
  572. [
  573. {
  574. "Id":"b750fe79269d",
  575. "Created":1364102658,
  576. "CreatedBy":"/bin/bash"
  577. },
  578. {
  579. "Id":"27cf78414709",
  580. "Created":1364068391,
  581. "CreatedBy":""
  582. }
  583. ]
  584. :statuscode 200: no error
  585. :statuscode 404: no such image
  586. :statuscode 500: server error
  587. Push an image on the registry
  588. *****************************
  589. .. http:post:: /images/(name)/push
  590. Push the image ``name`` on the registry
  591. **Example request**:
  592. .. sourcecode:: http
  593. POST /images/test/push HTTP/1.1
  594. **Example response**:
  595. .. sourcecode:: http
  596. HTTP/1.1 200 OK
  597. Content-Type: application/json
  598. {"status":"Pushing..."}
  599. {"status":"Pushing", "progress":"1/? (n/a)"}
  600. {"error":"Invalid..."}
  601. ...
  602. The ``X-Registry-Auth`` header can be used to include a
  603. base64-encoded AuthConfig object.
  604. :query registry: the registry you wan to push, optional
  605. :statuscode 200: no error
  606. :statuscode 404: no such image
  607. :statuscode 500: server error
  608. Tag an image into a repository
  609. ******************************
  610. .. http:post:: /images/(name)/tag
  611. Tag the image ``name`` into a repository
  612. **Example request**:
  613. .. sourcecode:: http
  614. POST /images/test/tag?repo=myrepo&force=0 HTTP/1.1
  615. **Example response**:
  616. .. sourcecode:: http
  617. HTTP/1.1 200 OK
  618. :query repo: The repository to tag in
  619. :query force: 1/True/true or 0/False/false, default false
  620. :statuscode 200: no error
  621. :statuscode 400: bad parameter
  622. :statuscode 404: no such image
  623. :statuscode 409: conflict
  624. :statuscode 500: server error
  625. Remove an image
  626. ***************
  627. .. http:delete:: /images/(name)
  628. Remove the image ``name`` from the filesystem
  629. **Example request**:
  630. .. sourcecode:: http
  631. DELETE /images/test HTTP/1.1
  632. **Example response**:
  633. .. sourcecode:: http
  634. HTTP/1.1 200 OK
  635. Content-type: application/json
  636. [
  637. {"Untagged":"3e2f21a89f"},
  638. {"Deleted":"3e2f21a89f"},
  639. {"Deleted":"53b4f83ac9"}
  640. ]
  641. :statuscode 200: no error
  642. :statuscode 404: no such image
  643. :statuscode 409: conflict
  644. :statuscode 500: server error
  645. Search images
  646. *************
  647. .. http:get:: /images/search
  648. Search for an image in the docker index
  649. **Example request**:
  650. .. sourcecode:: http
  651. GET /images/search?term=sshd HTTP/1.1
  652. **Example response**:
  653. .. sourcecode:: http
  654. HTTP/1.1 200 OK
  655. Content-Type: application/json
  656. [
  657. {
  658. "Name":"cespare/sshd",
  659. "Description":""
  660. },
  661. {
  662. "Name":"johnfuller/sshd",
  663. "Description":""
  664. },
  665. {
  666. "Name":"dhrp/mongodb-sshd",
  667. "Description":""
  668. }
  669. ]
  670. :query term: term to search
  671. :statuscode 200: no error
  672. :statuscode 500: server error
  673. 2.3 Misc
  674. --------
  675. Build an image from Dockerfile via stdin
  676. ****************************************
  677. .. http:post:: /build
  678. Build an image from Dockerfile via stdin
  679. **Example request**:
  680. .. sourcecode:: http
  681. POST /build HTTP/1.1
  682. {{ STREAM }}
  683. **Example response**:
  684. .. sourcecode:: http
  685. HTTP/1.1 200 OK
  686. {{ STREAM }}
  687. The stream must be a tar archive compressed with one of the following algorithms:
  688. identity (no compression), gzip, bzip2, xz. The archive must include a file called
  689. `Dockerfile` at its root. It may include any number of other files, which will be
  690. accessible in the build context (See the ADD build command).
  691. The Content-type header should be set to "application/tar".
  692. :query t: repository name (and optionally a tag) to be applied to the resulting image in case of success
  693. :query q: suppress verbose build output
  694. :query nocache: do not use the cache when building the image
  695. :statuscode 200: no error
  696. :statuscode 500: server error
  697. Check auth configuration
  698. ************************
  699. .. http:post:: /auth
  700. Get the default username and email
  701. **Example request**:
  702. .. sourcecode:: http
  703. POST /auth HTTP/1.1
  704. Content-Type: application/json
  705. {
  706. "username":"hannibal",
  707. "password:"xxxx",
  708. "email":"hannibal@a-team.com",
  709. "serveraddress":"https://index.docker.io/v1/"
  710. }
  711. **Example response**:
  712. .. sourcecode:: http
  713. HTTP/1.1 200 OK
  714. :statuscode 200: no error
  715. :statuscode 204: no error
  716. :statuscode 500: server error
  717. Display system-wide information
  718. *******************************
  719. .. http:get:: /info
  720. Display system-wide information
  721. **Example request**:
  722. .. sourcecode:: http
  723. GET /info HTTP/1.1
  724. **Example response**:
  725. .. sourcecode:: http
  726. HTTP/1.1 200 OK
  727. Content-Type: application/json
  728. {
  729. "Containers":11,
  730. "Images":16,
  731. "Debug":false,
  732. "NFd": 11,
  733. "NGoroutines":21,
  734. "MemoryLimit":true,
  735. "SwapLimit":false,
  736. "IPv4Forwarding":true
  737. }
  738. :statuscode 200: no error
  739. :statuscode 500: server error
  740. Show the docker version information
  741. ***********************************
  742. .. http:get:: /version
  743. Show the docker version information
  744. **Example request**:
  745. .. sourcecode:: http
  746. GET /version HTTP/1.1
  747. **Example response**:
  748. .. sourcecode:: http
  749. HTTP/1.1 200 OK
  750. Content-Type: application/json
  751. {
  752. "Version":"0.2.2",
  753. "GitCommit":"5a2a5cc+CHANGES",
  754. "GoVersion":"go1.0.3"
  755. }
  756. :statuscode 200: no error
  757. :statuscode 500: server error
  758. Create a new image from a container's changes
  759. *********************************************
  760. .. http:post:: /commit
  761. Create a new image from a container's changes
  762. **Example request**:
  763. .. sourcecode:: http
  764. POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
  765. **Example response**:
  766. .. sourcecode:: http
  767. HTTP/1.1 201 OK
  768. Content-Type: application/vnd.docker.raw-stream
  769. {"Id":"596069db4bf5"}
  770. :query container: source container
  771. :query repo: repository
  772. :query tag: tag
  773. :query m: commit message
  774. :query author: author (eg. "John Hannibal Smith <hannibal@a-team.com>")
  775. :query run: config automatically applied when the image is run. (ex: {"Cmd": ["cat", "/world"], "PortSpecs":["22"]})
  776. :statuscode 201: no error
  777. :statuscode 404: no such container
  778. :statuscode 500: server error
  779. Monitor Docker's events
  780. ***********************
  781. .. http:get:: /events
  782. Get events from docker, either in real time via streaming, or via polling (using `since`)
  783. **Example request**:
  784. .. sourcecode:: http
  785. POST /events?since=1374067924
  786. **Example response**:
  787. .. sourcecode:: http
  788. HTTP/1.1 200 OK
  789. Content-Type: application/json
  790. {"status":"create","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
  791. {"status":"start","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
  792. {"status":"stop","id":"dfdf82bd3881","from":"base:latest","time":1374067966}
  793. {"status":"destroy","id":"dfdf82bd3881","from":"base:latest","time":1374067970}
  794. :query since: timestamp used for polling
  795. :statuscode 200: no error
  796. :statuscode 500: server error
  797. 3. Going further
  798. ================
  799. 3.1 Inside 'docker run'
  800. -----------------------
  801. Here are the steps of 'docker run' :
  802. * Create the container
  803. * If the status code is 404, it means the image doesn't exists:
  804. * Try to pull it
  805. * Then retry to create the container
  806. * Start the container
  807. * If you are not in detached mode:
  808. * Attach to the container, using logs=1 (to have stdout and stderr from the container's start) and stream=1
  809. * If in detached mode or only stdin is attached:
  810. * Display the container's id
  811. 3.2 Hijacking
  812. -------------
  813. 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.
  814. 3.3 CORS Requests
  815. -----------------
  816. To enable cross origin requests to the remote api add the flag "-api-enable-cors" when running docker in daemon mode.
  817. .. code-block:: bash
  818. docker -d -H="192.168.1.9:4243" -api-enable-cors