docker_remote_api_v1.10.rst 33 KB

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