docker_remote_api_v1.8.rst 34 KB

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