docker_remote_api_v1.7.rst 25 KB

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