docker_remote_api_v1.7.rst 26 KB

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