docker_remote_api_v1.8.rst 26 KB

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