docker_remote_api.rst 19 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  1. :title: Remote API
  2. :description: API Documentation for Docker
  3. :keywords: API, Docker, rcli, REST, documentation
  4. =================
  5. Docker Remote API
  6. =================
  7. .. contents:: Table of Contents
  8. 1. Brief introduction
  9. =====================
  10. - The Remote API is replacing rcli
  11. - Default port in the docker deamon is 4243
  12. - The API tends to be REST, but for some complex commands, like attach or pull, the HTTP connection is hijacked to transport stdout stdin and stderr
  13. 2. Endpoints
  14. ============
  15. 2.1 Containers
  16. --------------
  17. List containers
  18. ***************
  19. .. http:get:: /containers/json
  20. List containers
  21. **Example request**:
  22. .. sourcecode:: http
  23. GET /containers/json?all=1&before=8dfafdbc3a40 HTTP/1.1
  24. **Example response**:
  25. .. sourcecode:: http
  26. HTTP/1.1 200 OK
  27. Content-Type: application/json
  28. [
  29. {
  30. "Id": "8dfafdbc3a40",
  31. "Image": "base:latest",
  32. "Command": "echo 1",
  33. "Created": 1367854155,
  34. "Status": "Exit 0"
  35. },
  36. {
  37. "Id": "9cd87474be90",
  38. "Image": "base:latest",
  39. "Command": "echo 222222",
  40. "Created": 1367854155,
  41. "Status": "Exit 0"
  42. },
  43. {
  44. "Id": "3176a2479c92",
  45. "Image": "base:latest",
  46. "Command": "echo 3333333333333333",
  47. "Created": 1367854154,
  48. "Status": "Exit 0"
  49. },
  50. {
  51. "Id": "4cb07b47f9fb",
  52. "Image": "base:latest",
  53. "Command": "echo 444444444444444444444444444444444",
  54. "Created": 1367854152,
  55. "Status": "Exit 0"
  56. }
  57. ]
  58. :query all: 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default
  59. :query limit: Show ``limit`` last created containers, include non-running ones.
  60. :query since: Show only containers created since Id, include non-running ones.
  61. :query before: Show only containers created before Id, include non-running ones.
  62. :statuscode 200: no error
  63. :statuscode 400: bad parameter
  64. :statuscode 500: server error
  65. Create a container
  66. ******************
  67. .. http:post:: /containers/create
  68. Create a container
  69. **Example request**:
  70. .. sourcecode:: http
  71. POST /containers/create HTTP/1.1
  72. Content-Type: application/json
  73. {
  74. "Hostname":"",
  75. "User":"",
  76. "Memory":0,
  77. "MemorySwap":0,
  78. "AttachStdin":false,
  79. "AttachStdout":true,
  80. "AttachStderr":true,
  81. "PortSpecs":null,
  82. "Tty":false,
  83. "OpenStdin":false,
  84. "StdinOnce":false,
  85. "Env":null,
  86. "Cmd":[
  87. "date"
  88. ],
  89. "Dns":null,
  90. "Image":"base",
  91. "Volumes":{},
  92. "VolumesFrom":""
  93. }
  94. **Example response**:
  95. .. sourcecode:: http
  96. HTTP/1.1 201 OK
  97. Content-Type: application/json
  98. {
  99. "Id":"e90e34656806"
  100. "Warnings":[]
  101. }
  102. :jsonparam config: the container's configuration
  103. :statuscode 201: no error
  104. :statuscode 404: no such container
  105. :statuscode 406: impossible to attach (container not running)
  106. :statuscode 500: server error
  107. Inspect a container
  108. *******************
  109. .. http:get:: /containers/(id)/json
  110. Return low-level information on the container ``id``
  111. **Example request**:
  112. .. sourcecode:: http
  113. GET /containers/4fa6e0f0c678/json HTTP/1.1
  114. **Example response**:
  115. .. sourcecode:: http
  116. HTTP/1.1 200 OK
  117. Content-Type: application/json
  118. {
  119. "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
  120. "Created": "2013-05-07T14:51:42.041847+02:00",
  121. "Path": "date",
  122. "Args": [],
  123. "Config": {
  124. "Hostname": "4fa6e0f0c678",
  125. "User": "",
  126. "Memory": 0,
  127. "MemorySwap": 0,
  128. "AttachStdin": false,
  129. "AttachStdout": true,
  130. "AttachStderr": true,
  131. "PortSpecs": null,
  132. "Tty": false,
  133. "OpenStdin": false,
  134. "StdinOnce": false,
  135. "Env": null,
  136. "Cmd": [
  137. "date"
  138. ],
  139. "Dns": null,
  140. "Image": "base",
  141. "Volumes": {},
  142. "VolumesFrom": ""
  143. },
  144. "State": {
  145. "Running": false,
  146. "Pid": 0,
  147. "ExitCode": 0,
  148. "StartedAt": "2013-05-07T14:51:42.087658+02:01360",
  149. "Ghost": false
  150. },
  151. "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  152. "NetworkSettings": {
  153. "IpAddress": "",
  154. "IpPrefixLen": 0,
  155. "Gateway": "",
  156. "Bridge": "",
  157. "PortMapping": null
  158. },
  159. "SysInitPath": "/home/kitty/go/src/github.com/dotcloud/docker/bin/docker",
  160. "ResolvConfPath": "/etc/resolv.conf",
  161. "Volumes": {}
  162. }
  163. :statuscode 200: no error
  164. :statuscode 404: no such container
  165. :statuscode 500: server error
  166. Inspect changes on a container's filesystem
  167. *******************************************
  168. .. http:get:: /containers/(id)/changes
  169. Inspect changes on container ``id`` 's filesystem
  170. **Example request**:
  171. .. sourcecode:: http
  172. GET /containers/4fa6e0f0c678/changes HTTP/1.1
  173. **Example response**:
  174. .. sourcecode:: http
  175. HTTP/1.1 200 OK
  176. Content-Type: application/json
  177. [
  178. {
  179. "Path":"/dev",
  180. "Kind":0
  181. },
  182. {
  183. "Path":"/dev/kmsg",
  184. "Kind":1
  185. },
  186. {
  187. "Path":"/test",
  188. "Kind":1
  189. }
  190. ]
  191. :statuscode 200: no error
  192. :statuscode 404: no such container
  193. :statuscode 500: server error
  194. Export a container
  195. ******************
  196. .. http:get:: /containers/(id)/export
  197. Export the contents of container ``id``
  198. **Example request**:
  199. .. sourcecode:: http
  200. GET /containers/4fa6e0f0c678/export HTTP/1.1
  201. **Example response**:
  202. .. sourcecode:: http
  203. HTTP/1.1 200 OK
  204. Content-Type: application/octet-stream
  205. {{ STREAM }}
  206. :statuscode 200: no error
  207. :statuscode 404: no such container
  208. :statuscode 500: server error
  209. Start a container
  210. *****************
  211. .. http:post:: /containers/(id)/start
  212. Start the container ``id``
  213. **Example request**:
  214. .. sourcecode:: http
  215. POST /containers/e90e34656806/start HTTP/1.1
  216. **Example response**:
  217. .. sourcecode:: http
  218. HTTP/1.1 200 OK
  219. :statuscode 200: no error
  220. :statuscode 404: no such container
  221. :statuscode 500: server error
  222. Stop a contaier
  223. ***************
  224. .. http:post:: /containers/(id)/stop
  225. Stop the container ``id``
  226. **Example request**:
  227. .. sourcecode:: http
  228. POST /containers/e90e34656806/stop?t=5 HTTP/1.1
  229. **Example response**:
  230. .. sourcecode:: http
  231. HTTP/1.1 204 OK
  232. :query t: number of seconds to wait before killing the container
  233. :statuscode 204: no error
  234. :statuscode 404: no such container
  235. :statuscode 500: server error
  236. Restart a container
  237. *******************
  238. .. http:post:: /containers/(id)/restart
  239. Restart the container ``id``
  240. **Example request**:
  241. .. sourcecode:: http
  242. POST /containers/e90e34656806/restart?t=5 HTTP/1.1
  243. **Example response**:
  244. .. sourcecode:: http
  245. HTTP/1.1 204 OK
  246. :query t: number of seconds to wait before killing the container
  247. :statuscode 204: no error
  248. :statuscode 404: no such container
  249. :statuscode 500: server error
  250. Kill a container
  251. ****************
  252. .. http:post:: /containers/(id)/kill
  253. Kill the container ``id``
  254. **Example request**:
  255. .. sourcecode:: http
  256. POST /containers/e90e34656806/kill HTTP/1.1
  257. **Example response**:
  258. .. sourcecode:: http
  259. HTTP/1.1 204 OK
  260. :statuscode 204: no error
  261. :statuscode 404: no such container
  262. :statuscode 500: server error
  263. Attach to a container
  264. *********************
  265. .. http:post:: /containers/(id)/attach
  266. Attach to the container ``id``
  267. **Example request**:
  268. .. sourcecode:: http
  269. POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
  270. **Example response**:
  271. .. sourcecode:: http
  272. HTTP/1.1 200 OK
  273. Content-Type: application/vnd.docker.raw-stream
  274. {{ STREAM }}
  275. :query logs: 1/True/true or 0/False/false, return logs. Default false
  276. :query stream: 1/True/true or 0/False/false, return stream. Default false
  277. :query stdin: 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false
  278. :query stdout: 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false
  279. :query stderr: 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false
  280. :statuscode 200: no error
  281. :statuscode 400: bad parameter
  282. :statuscode 404: no such container
  283. :statuscode 500: server error
  284. Wait a container
  285. ****************
  286. .. http:post:: /containers/(id)/wait
  287. Block until container ``id`` stops, then returns the exit code
  288. **Example request**:
  289. .. sourcecode:: http
  290. POST /containers/16253994b7c4/wait HTTP/1.1
  291. **Example response**:
  292. .. sourcecode:: http
  293. HTTP/1.1 200 OK
  294. Content-Type: application/json
  295. {"StatusCode":0}
  296. :statuscode 200: no error
  297. :statuscode 404: no such container
  298. :statuscode 500: server error
  299. Remove a container
  300. *******************
  301. .. http:delete:: /containers/(id)
  302. Remove the container ``id`` from the filesystem
  303. **Example request**:
  304. .. sourcecode:: http
  305. DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  306. **Example response**:
  307. .. sourcecode:: http
  308. HTTP/1.1 204 OK
  309. :query v: 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false
  310. :statuscode 204: no error
  311. :statuscode 400: bad parameter
  312. :statuscode 404: no such container
  313. :statuscode 500: server error
  314. 2.2 Images
  315. ----------
  316. List Images
  317. ***********
  318. .. http:get:: /images/(format)
  319. List images ``format`` could be json or viz (json default)
  320. **Example request**:
  321. .. sourcecode:: http
  322. GET /images/json?all=0 HTTP/1.1
  323. **Example response**:
  324. .. sourcecode:: http
  325. HTTP/1.1 200 OK
  326. Content-Type: application/json
  327. [
  328. {
  329. "Repository":"base",
  330. "Tag":"ubuntu-12.10",
  331. "Id":"b750fe79269d",
  332. "Created":1364102658
  333. },
  334. {
  335. "Repository":"base",
  336. "Tag":"ubuntu-quantal",
  337. "Id":"b750fe79269d",
  338. "Created":1364102658
  339. }
  340. ]
  341. **Example request**:
  342. .. sourcecode:: http
  343. GET /images/viz HTTP/1.1
  344. **Example response**:
  345. .. sourcecode:: http
  346. HTTP/1.1 200 OK
  347. Content-Type: text/plain
  348. digraph docker {
  349. "d82cbacda43a" -> "074be284591f"
  350. "1496068ca813" -> "08306dc45919"
  351. "08306dc45919" -> "0e7893146ac2"
  352. "b750fe79269d" -> "1496068ca813"
  353. base -> "27cf78414709" [style=invis]
  354. "f71189fff3de" -> "9a33b36209ed"
  355. "27cf78414709" -> "b750fe79269d"
  356. "0e7893146ac2" -> "d6434d954665"
  357. "d6434d954665" -> "d82cbacda43a"
  358. base -> "e9aa60c60128" [style=invis]
  359. "074be284591f" -> "f71189fff3de"
  360. "b750fe79269d" [label="b750fe79269d\nbase",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  361. "e9aa60c60128" [label="e9aa60c60128\nbase2",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  362. "9a33b36209ed" [label="9a33b36209ed\ntest",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  363. base [style=invisible]
  364. }
  365. :query all: 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default
  366. :statuscode 200: no error
  367. :statuscode 400: bad parameter
  368. :statuscode 500: server error
  369. Create an image
  370. ***************
  371. .. http:post:: /images/create
  372. Create an image, either by pull it from the registry or by importing it
  373. **Example request**:
  374. .. sourcecode:: http
  375. POST /images/create?fromImage=base HTTP/1.1
  376. **Example response**:
  377. .. sourcecode:: http
  378. HTTP/1.1 200 OK
  379. Content-Type: application/vnd.docker.raw-stream
  380. {{ STREAM }}
  381. :query fromImage: name of the image to pull
  382. :query fromSrc: source to import, - means stdin
  383. :query repo: repository
  384. :query tag: tag
  385. :query registry: the registry to pull from
  386. :statuscode 200: no error
  387. :statuscode 500: server error
  388. Insert a file in a image
  389. ************************
  390. .. http:post:: /images/(name)/insert
  391. Insert a file from ``url`` in the image ``name`` at ``path``
  392. **Example request**:
  393. .. sourcecode:: http
  394. POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
  395. **Example response**:
  396. .. sourcecode:: http
  397. HTTP/1.1 200 OK
  398. {{ STREAM }}
  399. :statuscode 200: no error
  400. :statuscode 500: server error
  401. Inspect an image
  402. ****************
  403. .. http:get:: /images/(name)/json
  404. Return low-level information on the image ``name``
  405. **Example request**:
  406. .. sourcecode:: http
  407. GET /images/base/json HTTP/1.1
  408. **Example response**:
  409. .. sourcecode:: http
  410. HTTP/1.1 200 OK
  411. Content-Type: application/json
  412. {
  413. "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  414. "parent":"27cf784147099545",
  415. "created":"2013-03-23T22:24:18.818426-07:00",
  416. "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  417. "container_config":
  418. {
  419. "Hostname":"",
  420. "User":"",
  421. "Memory":0,
  422. "MemorySwap":0,
  423. "AttachStdin":false,
  424. "AttachStdout":false,
  425. "AttachStderr":false,
  426. "PortSpecs":null,
  427. "Tty":true,
  428. "OpenStdin":true,
  429. "StdinOnce":false,
  430. "Env":null,
  431. "Cmd": ["/bin/bash"]
  432. ,"Dns":null,
  433. "Image":"base",
  434. "Volumes":null,
  435. "VolumesFrom":""
  436. }
  437. }
  438. :statuscode 200: no error
  439. :statuscode 404: no such image
  440. :statuscode 500: server error
  441. Get the history of an image
  442. ***************************
  443. .. http:get:: /images/(name)/history
  444. Return the history of the image ``name``
  445. **Example request**:
  446. .. sourcecode:: http
  447. GET /images/base/history HTTP/1.1
  448. **Example response**:
  449. .. sourcecode:: http
  450. HTTP/1.1 200 OK
  451. Content-Type: application/json
  452. [
  453. {
  454. "Id":"b750fe79269d",
  455. "Created":1364102658,
  456. "CreatedBy":"/bin/bash"
  457. },
  458. {
  459. "Id":"27cf78414709",
  460. "Created":1364068391,
  461. "CreatedBy":""
  462. }
  463. ]
  464. :statuscode 200: no error
  465. :statuscode 404: no such image
  466. :statuscode 500: server error
  467. Push an image on the registry
  468. *****************************
  469. .. http:post:: /images/(name)/push
  470. Push the image ``name`` on the registry
  471. **Example request**:
  472. .. sourcecode:: http
  473. POST /images/test/push HTTP/1.1
  474. **Example response**:
  475. .. sourcecode:: http
  476. HTTP/1.1 200 OK
  477. Content-Type: application/vnd.docker.raw-stream
  478. {{ STREAM }}
  479. :query registry: the registry you wan to push, optional
  480. :statuscode 200: no error
  481. :statuscode 404: no such image
  482. :statuscode 500: server error
  483. Tag an image into a repository
  484. ******************************
  485. .. http:post:: /images/(name)/tag
  486. Tag the image ``name`` into a repository
  487. **Example request**:
  488. .. sourcecode:: http
  489. POST /images/test/tag?repo=myrepo&force=0 HTTP/1.1
  490. **Example response**:
  491. .. sourcecode:: http
  492. HTTP/1.1 200 OK
  493. :query repo: The repository to tag in
  494. :query force: 1/True/true or 0/False/false, default false
  495. :statuscode 200: no error
  496. :statuscode 400: bad parameter
  497. :statuscode 404: no such image
  498. :statuscode 500: server error
  499. Remove an image
  500. ***************
  501. .. http:delete:: /images/(name)
  502. Remove the image ``name`` from the filesystem
  503. **Example request**:
  504. .. sourcecode:: http
  505. DELETE /images/test HTTP/1.1
  506. **Example response**:
  507. .. sourcecode:: http
  508. HTTP/1.1 204 OK
  509. :statuscode 204: no error
  510. :statuscode 404: no such image
  511. :statuscode 500: server error
  512. Search images
  513. *************
  514. .. http:get:: /images/search
  515. Search for an image in the docker index
  516. **Example request**:
  517. .. sourcecode:: http
  518. GET /images/search?term=sshd HTTP/1.1
  519. **Example response**:
  520. .. sourcecode:: http
  521. HTTP/1.1 200 OK
  522. Content-Type: application/json
  523. [
  524. {
  525. "Name":"cespare/sshd",
  526. "Description":""
  527. },
  528. {
  529. "Name":"johnfuller/sshd",
  530. "Description":""
  531. },
  532. {
  533. "Name":"dhrp/mongodb-sshd",
  534. "Description":""
  535. }
  536. ]
  537. :query term: term to search
  538. :statuscode 200: no error
  539. :statuscode 500: server error
  540. 2.3 Misc
  541. --------
  542. Build an image from Dockerfile via stdin
  543. ****************************************
  544. .. http:post:: /build
  545. Build an image from Dockerfile via stdin
  546. **Example request**:
  547. .. sourcecode:: http
  548. POST /build HTTP/1.1
  549. {{ STREAM }}
  550. **Example response**:
  551. .. sourcecode:: http
  552. HTTP/1.1 200 OK
  553. {{ STREAM }}
  554. :query t: tag to be applied to the resulting image in case of success
  555. :statuscode 200: no error
  556. :statuscode 500: server error
  557. Get default username and email
  558. ******************************
  559. .. http:get:: /auth
  560. Get the default username and email
  561. **Example request**:
  562. .. sourcecode:: http
  563. GET /auth HTTP/1.1
  564. **Example response**:
  565. .. sourcecode:: http
  566. HTTP/1.1 200 OK
  567. Content-Type: application/json
  568. {
  569. "username":"hannibal",
  570. "email":"hannibal@a-team.com"
  571. }
  572. :statuscode 200: no error
  573. :statuscode 500: server error
  574. Set auth configuration
  575. **********************
  576. .. http:post:: /auth
  577. Get the default username and email
  578. **Example request**:
  579. .. sourcecode:: http
  580. POST /auth HTTP/1.1
  581. Content-Type: application/json
  582. {
  583. "username":"hannibal",
  584. "password:"xxxx",
  585. "email":"hannibal@a-team.com"
  586. }
  587. **Example response**:
  588. .. sourcecode:: http
  589. HTTP/1.1 200 OK
  590. :statuscode 200: no error
  591. :statuscode 204: no error
  592. :statuscode 500: server error
  593. Display system-wide information
  594. *******************************
  595. .. http:get:: /info
  596. Display system-wide information
  597. **Example request**:
  598. .. sourcecode:: http
  599. GET /info HTTP/1.1
  600. **Example response**:
  601. .. sourcecode:: http
  602. HTTP/1.1 200 OK
  603. Content-Type: application/json
  604. {
  605. "Containers":11,
  606. "Images":16,
  607. "Debug":false,
  608. "NFd": 11,
  609. "NGoroutines":21,
  610. "MemoryLimit":true,
  611. "SwapLimit":false
  612. }
  613. :statuscode 200: no error
  614. :statuscode 500: server error
  615. Show the docker version information
  616. ***********************************
  617. .. http:get:: /version
  618. Show the docker version information
  619. **Example request**:
  620. .. sourcecode:: http
  621. GET /version HTTP/1.1
  622. **Example response**:
  623. .. sourcecode:: http
  624. HTTP/1.1 200 OK
  625. Content-Type: application/json
  626. {
  627. "Version":"0.2.2",
  628. "GitCommit":"5a2a5cc+CHANGES",
  629. "GoVersion":"go1.0.3"
  630. }
  631. :statuscode 200: no error
  632. :statuscode 500: server error
  633. Create a new image from a container's changes
  634. *********************************************
  635. .. http:post:: /commit
  636. Create a new image from a container's changes
  637. **Example request**:
  638. .. sourcecode:: http
  639. POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
  640. **Example response**:
  641. .. sourcecode:: http
  642. HTTP/1.1 201 OK
  643. Content-Type: application/vnd.docker.raw-stream
  644. {"Id":"596069db4bf5"}
  645. :query container: source container
  646. :query repo: repository
  647. :query tag: tag
  648. :query m: commit message
  649. :query author: author (eg. "John Hannibal Smith <hannibal@a-team.com>")
  650. :query run: config automatically applied when the image is run. (ex: {"Cmd": ["cat", "/world"], "PortSpecs":["22"]})
  651. :statuscode 201: no error
  652. :statuscode 404: no such container
  653. :statuscode 500: server error
  654. 3. Going further
  655. ================
  656. 3.1 Inside 'docker run'
  657. -----------------------
  658. Here are the steps of 'docker run' :
  659. * Create the container
  660. * If the status code is 404, it means the image doesn't exists:
  661. * Try to pull it
  662. * Then retry to create the container
  663. * Start the container
  664. * If you are not in detached mode:
  665. * Attach to the container, using logs=1 (to have stdout and stderr from the container's start) and stream=1
  666. * If in detached mode or only stdin is attached:
  667. * Display the container's id
  668. 3.2 Hijacking
  669. -------------
  670. In this first version of the API, some of the endpoints, like /attach, /pull or /push uses hijacking to transport stdin,
  671. stdout and stderr on the same socket. This might change in the future.