docker_remote_api_v1.8.rst 26 KB

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