docker_remote_api_v1.10.rst 33 KB

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