docker_remote_api_v1.10.rst 33 KB

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