docker_remote_api_v1.7.rst 26 KB

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