docker_remote_api_v1.10.rst 33 KB

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