docker_remote_api_v1.7.rst 25 KB

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