docker_remote_api_v1.11.rst 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285
  1. :title: Remote API v1.11
  2. :description: API Documentation for Docker
  3. :keywords: API, Docker, rcli, REST, documentation
  4. :orphan:
  5. =======================
  6. Docker Remote API v1.11
  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. "Dns":null,
  106. "Image":"base",
  107. "Volumes":{
  108. "/tmp": {}
  109. },
  110. "VolumesFrom":"",
  111. "WorkingDir":"",
  112. "DisableNetwork": false,
  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. :query signal: Signal to send to the container, must be integer or string (i.e. SIGINT). When not set, SIGKILL is assumed and the call will waits for the container to exit.
  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. :query until: timestamp used for polling
  824. :statuscode 200: no error
  825. :statuscode 500: server error
  826. Get a tarball containing all images and tags in a repository
  827. ************************************************************
  828. .. http:get:: /images/(name)/get
  829. Get a tarball containing all images and metadata for the repository specified by ``name``.
  830. **Example request**
  831. .. sourcecode:: http
  832. GET /images/ubuntu/get
  833. **Example response**:
  834. .. sourcecode:: http
  835. HTTP/1.1 200 OK
  836. Content-Type: application/x-tar
  837. Binary data stream
  838. :statuscode 200: no error
  839. :statuscode 500: server error
  840. Load a tarball with a set of images and tags into docker
  841. ********************************************************
  842. .. http:post:: /images/load
  843. Load a set of images and tags into the docker repository.
  844. **Example request**
  845. .. sourcecode:: http
  846. POST /images/load
  847. Tarball in body
  848. **Example response**:
  849. .. sourcecode:: http
  850. HTTP/1.1 200 OK
  851. :statuscode 200: no error
  852. :statuscode 500: server error
  853. 3. Going further
  854. ================
  855. 3.1 Inside 'docker run'
  856. -----------------------
  857. Here are the steps of 'docker run' :
  858. * Create the container
  859. * If the status code is 404, it means the image doesn't exists:
  860. * Try to pull it
  861. * Then retry to create the container
  862. * Start the container
  863. * If you are not in detached mode:
  864. * Attach to the container, using logs=1 (to have stdout and stderr from the container's start) and stream=1
  865. * If in detached mode or only stdin is attached:
  866. * Display the container's id
  867. 3.2 Hijacking
  868. -------------
  869. 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.
  870. 3.3 CORS Requests
  871. -----------------
  872. To enable cross origin requests to the remote api add the flag "--api-enable-cors" when running docker in daemon mode.
  873. .. code-block:: bash
  874. docker -d -H="192.168.1.9:4243" --api-enable-cors