cli.rst 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. :title: Command Line Interface
  2. :description: Docker's CLI command description and usage
  3. :keywords: Docker, Docker documentation, CLI, command line
  4. .. _cli:
  5. Command Line Help
  6. -----------------
  7. To list available commands, either run ``docker`` with no parameters or execute
  8. ``docker help``::
  9. $ sudo docker
  10. Usage: docker [OPTIONS] COMMAND [arg...]
  11. -H=[unix:///var/run/docker.sock]: tcp://host:port to bind/connect to or unix://path/to/socket to use
  12. A self-sufficient runtime for linux containers.
  13. ...
  14. .. _cli_attach:
  15. ``attach``
  16. ----------
  17. ::
  18. Usage: docker attach CONTAINER
  19. Attach to a running container.
  20. -nostdin=false: Do not attach stdin
  21. -sig-proxy=true: Proxify all received signal to the process (even in non-tty mode)
  22. You can detach from the container again (and leave it running) with
  23. ``CTRL-c`` (for a quiet exit) or ``CTRL-\`` to get a stacktrace of
  24. the Docker client when it quits.
  25. To stop a container, use ``docker stop``
  26. To kill the container, use ``docker kill``
  27. .. _cli_attach_examples:
  28. Examples:
  29. ~~~~~~~~~
  30. .. code-block:: bash
  31. $ ID=$(sudo docker run -d ubuntu /usr/bin/top -b)
  32. $ sudo docker attach $ID
  33. top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
  34. Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
  35. Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
  36. Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
  37. Swap: 786428k total, 0k used, 786428k free, 221740k cached
  38. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  39. 1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
  40. top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
  41. Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
  42. Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
  43. Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
  44. Swap: 786428k total, 0k used, 786428k free, 221776k cached
  45. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  46. 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
  47. top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05
  48. Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
  49. Cpu(s): 0.2%us, 0.3%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
  50. Mem: 373572k total, 355780k used, 17792k free, 27880k buffers
  51. Swap: 786428k total, 0k used, 786428k free, 221776k cached
  52. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  53. 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
  54. ^C$
  55. $ sudo docker stop $ID
  56. .. _cli_build:
  57. ``build``
  58. ---------
  59. ::
  60. Usage: docker build [OPTIONS] PATH | URL | -
  61. Build a new container image from the source code at PATH
  62. -t="": Repository name (and optionally a tag) to be applied
  63. to the resulting image in case of success.
  64. -q=false: Suppress verbose build output.
  65. -no-cache: Do not use the cache when building the image.
  66. -rm: Remove intermediate containers after a successful build
  67. The files at PATH or URL are called the "context" of the build. The
  68. build process may refer to any of the files in the context, for
  69. example when using an :ref:`ADD <dockerfile_add>` instruction. When a
  70. single ``Dockerfile`` is given as URL, then no context is set. When a
  71. git repository is set as URL, then the repository is used as the
  72. context
  73. .. _cli_build_examples:
  74. .. seealso:: :ref:`dockerbuilder`.
  75. Examples:
  76. ~~~~~~~~~
  77. .. code-block:: bash
  78. sudo docker build .
  79. Uploading context 10240 bytes
  80. Step 1 : FROM busybox
  81. Pulling repository busybox
  82. ---> e9aa60c60128MB/2.284 MB (100%) endpoint: https://cdn-registry-1.docker.io/v1/
  83. Step 2 : RUN ls -lh /
  84. ---> Running in 9c9e81692ae9
  85. total 24
  86. drwxr-xr-x 2 root root 4.0K Mar 12 2013 bin
  87. drwxr-xr-x 5 root root 4.0K Oct 19 00:19 dev
  88. drwxr-xr-x 2 root root 4.0K Oct 19 00:19 etc
  89. drwxr-xr-x 2 root root 4.0K Nov 15 23:34 lib
  90. lrwxrwxrwx 1 root root 3 Mar 12 2013 lib64 -> lib
  91. dr-xr-xr-x 116 root root 0 Nov 15 23:34 proc
  92. lrwxrwxrwx 1 root root 3 Mar 12 2013 sbin -> bin
  93. dr-xr-xr-x 13 root root 0 Nov 15 23:34 sys
  94. drwxr-xr-x 2 root root 4.0K Mar 12 2013 tmp
  95. drwxr-xr-x 2 root root 4.0K Nov 15 23:34 usr
  96. ---> b35f4035db3f
  97. Step 3 : CMD echo Hello World
  98. ---> Running in 02071fceb21b
  99. ---> f52f38b7823e
  100. Successfully built f52f38b7823e
  101. This example specifies that the PATH is ``.``, and so all the files in
  102. the local directory get tar'd and sent to the Docker daemon. The PATH
  103. specifies where to find the files for the "context" of the build on
  104. the Docker daemon. Remember that the daemon could be running on a
  105. remote machine and that no parsing of the Dockerfile happens at the
  106. client side (where you're running ``docker build``). That means that
  107. *all* the files at PATH get sent, not just the ones listed to
  108. :ref:`ADD <dockerfile_add>` in the ``Dockerfile``.
  109. The transfer of context from the local machine to the Docker daemon is
  110. what the ``docker`` client means when you see the "Uploading context"
  111. message.
  112. .. code-block:: bash
  113. sudo docker build -t vieux/apache:2.0 .
  114. This will build like the previous example, but it will then tag the
  115. resulting image. The repository name will be ``vieux/apache`` and the
  116. tag will be ``2.0``
  117. .. code-block:: bash
  118. sudo docker build - < Dockerfile
  119. This will read a ``Dockerfile`` from *stdin* without context. Due to
  120. the lack of a context, no contents of any local directory will be sent
  121. to the ``docker`` daemon. Since there is no context, a Dockerfile
  122. ``ADD`` only works if it refers to a remote URL.
  123. .. code-block:: bash
  124. sudo docker build github.com/creack/docker-firefox
  125. This will clone the Github repository and use the cloned repository as
  126. context. The ``Dockerfile`` at the root of the repository is used as
  127. ``Dockerfile``. Note that you can specify an arbitrary git repository
  128. by using the ``git://`` schema.
  129. .. _cli_commit:
  130. ``commit``
  131. ----------
  132. ::
  133. Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
  134. Create a new image from a container's changes
  135. -m="": Commit message
  136. -author="": Author (eg. "John Hannibal Smith <hannibal@a-team.com>"
  137. -run="": Configuration to be applied when the image is launched with `docker run`.
  138. (ex: -run='{"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')
  139. Simple commit of an existing container
  140. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  141. .. code-block:: bash
  142. $ docker ps
  143. ID IMAGE COMMAND CREATED STATUS PORTS
  144. c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
  145. 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
  146. $ docker commit c3f279d17e0a SvenDowideit/testimage:version3
  147. f5283438590d
  148. $ docker images | head
  149. REPOSITORY TAG ID CREATED SIZE
  150. SvenDowideit/testimage version3 f5283438590d 16 seconds ago 204.2 MB (virtual 335.7 MB)
  151. Full -run example
  152. .................
  153. (multiline is ok within a single quote ``'``)
  154. ::
  155. $ sudo docker commit -run='
  156. {
  157. "Entrypoint" : null,
  158. "Privileged" : false,
  159. "User" : "",
  160. "VolumesFrom" : "",
  161. "Cmd" : ["cat", "-e", "/etc/resolv.conf"],
  162. "Dns" : ["8.8.8.8", "8.8.4.4"],
  163. "MemorySwap" : 0,
  164. "AttachStdin" : false,
  165. "AttachStderr" : false,
  166. "CpuShares" : 0,
  167. "OpenStdin" : false,
  168. "Volumes" : null,
  169. "Hostname" : "122612f45831",
  170. "PortSpecs" : ["22", "80", "443"],
  171. "Image" : "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  172. "Tty" : false,
  173. "Env" : [
  174. "HOME=/",
  175. "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  176. ],
  177. "StdinOnce" : false,
  178. "Domainname" : "",
  179. "WorkingDir" : "/",
  180. "NetworkDisabled" : false,
  181. "Memory" : 0,
  182. "AttachStdout" : false
  183. }' $CONTAINER_ID
  184. .. _cli_cp:
  185. ``cp``
  186. ------
  187. ::
  188. Usage: docker cp CONTAINER:PATH HOSTPATH
  189. Copy files/folders from the containers filesystem to the host
  190. path. Paths are relative to the root of the filesystem.
  191. .. code-block:: bash
  192. $ sudo docker cp 7bb0e258aefe:/etc/debian_version .
  193. $ sudo docker cp blue_frog:/etc/hosts .
  194. .. _cli_diff:
  195. ``diff``
  196. --------
  197. ::
  198. Usage: docker diff CONTAINER
  199. List the changed files and directories in a container's filesystem
  200. There are 3 events that are listed in the 'diff':
  201. 1. ```A``` - Add
  202. 2. ```D``` - Delete
  203. 3. ```C``` - Change
  204. for example:
  205. .. code-block:: bash
  206. $ sudo docker diff 7bb0e258aefe
  207. C /dev
  208. A /dev/kmsg
  209. C /etc
  210. A /etc/mtab
  211. A /go
  212. A /go/src
  213. A /go/src/github.com
  214. A /go/src/github.com/dotcloud
  215. A /go/src/github.com/dotcloud/docker
  216. A /go/src/github.com/dotcloud/docker/.git
  217. ....
  218. .. _cli_events:
  219. ``events``
  220. ----------
  221. ::
  222. Usage: docker events
  223. Get real time events from the server
  224. -since="": Show previously created events and then stream.
  225. (either seconds since epoch, or date string as below)
  226. .. _cli_events_example:
  227. Examples
  228. ~~~~~~~~
  229. You'll need two shells for this example.
  230. Shell 1: Listening for events
  231. .............................
  232. .. code-block:: bash
  233. $ sudo docker events
  234. Shell 2: Start and Stop a Container
  235. ...................................
  236. .. code-block:: bash
  237. $ sudo docker start 4386fb97867d
  238. $ sudo docker stop 4386fb97867d
  239. Shell 1: (Again .. now showing events)
  240. ......................................
  241. .. code-block:: bash
  242. [2013-09-03 15:49:26 +0200 CEST] 4386fb97867d: (from 12de384bfb10) start
  243. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
  244. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
  245. Show events in the past from a specified time
  246. .............................................
  247. .. code-block:: bash
  248. $ sudo docker events -since 1378216169
  249. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
  250. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
  251. $ sudo docker events -since '2013-09-03'
  252. [2013-09-03 15:49:26 +0200 CEST] 4386fb97867d: (from 12de384bfb10) start
  253. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
  254. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
  255. $ sudo docker events -since '2013-09-03 15:49:29 +0200 CEST'
  256. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
  257. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
  258. .. _cli_export:
  259. ``export``
  260. ----------
  261. ::
  262. Usage: docker export CONTAINER
  263. Export the contents of a filesystem as a tar archive
  264. .. _cli_history:
  265. ``history``
  266. -----------
  267. ::
  268. Usage: docker history [OPTIONS] IMAGE
  269. Show the history of an image
  270. -notrunc=false: Don't truncate output
  271. -q=false: only show numeric IDs
  272. To see how the docker:latest image was built:
  273. .. code-block:: bash
  274. $ docker history docker
  275. ID CREATED CREATED BY
  276. docker:latest 19 hours ago /bin/sh -c #(nop) ADD . in /go/src/github.com/dotcloud/docker
  277. cf5f2467662d 2 weeks ago /bin/sh -c #(nop) ENTRYPOINT ["hack/dind"]
  278. 3538fbe372bf 2 weeks ago /bin/sh -c #(nop) WORKDIR /go/src/github.com/dotcloud/docker
  279. 7450f65072e5 2 weeks ago /bin/sh -c #(nop) VOLUME /var/lib/docker
  280. b79d62b97328 2 weeks ago /bin/sh -c apt-get install -y -q lxc
  281. 36714852a550 2 weeks ago /bin/sh -c apt-get install -y -q iptables
  282. 8c4c706df1d6 2 weeks ago /bin/sh -c /bin/echo -e '[default]\naccess_key=$AWS_ACCESS_KEY\nsecret_key=$AWS_SECRET_KEYn' > /.s3cfg
  283. b89989433c48 2 weeks ago /bin/sh -c pip install python-magic
  284. a23e640d85b5 2 weeks ago /bin/sh -c pip install s3cmd
  285. 41f54fec7e79 2 weeks ago /bin/sh -c apt-get install -y -q python-pip
  286. d9bc04add907 2 weeks ago /bin/sh -c apt-get install -y -q reprepro dpkg-sig
  287. e74f4760fa70 2 weeks ago /bin/sh -c gem install --no-rdoc --no-ri fpm
  288. 1e43224726eb 2 weeks ago /bin/sh -c apt-get install -y -q ruby1.9.3 rubygems libffi-dev
  289. 460953ae9d7f 2 weeks ago /bin/sh -c #(nop) ENV GOPATH=/go:/go/src/github.com/dotcloud/docker/vendor
  290. 8b63eb1d666b 2 weeks ago /bin/sh -c #(nop) ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/goroot/bin
  291. 3087f3bcedf2 2 weeks ago /bin/sh -c #(nop) ENV GOROOT=/goroot
  292. 635840d198e5 2 weeks ago /bin/sh -c cd /goroot/src && ./make.bash
  293. 439f4a0592ba 2 weeks ago /bin/sh -c curl -s https://go.googlecode.com/files/go1.1.2.src.tar.gz | tar -v -C / -xz && mv /go /goroot
  294. 13967ed36e93 2 weeks ago /bin/sh -c #(nop) ENV CGO_ENABLED=0
  295. bf7424458437 2 weeks ago /bin/sh -c apt-get install -y -q build-essential
  296. a89ec997c3bf 2 weeks ago /bin/sh -c apt-get install -y -q mercurial
  297. b9f165c6e749 2 weeks ago /bin/sh -c apt-get install -y -q git
  298. 17a64374afa7 2 weeks ago /bin/sh -c apt-get install -y -q curl
  299. d5e85dc5b1d8 2 weeks ago /bin/sh -c apt-get update
  300. 13e642467c11 2 weeks ago /bin/sh -c echo 'deb http://archive.ubuntu.com/ubuntu precise main universe' > /etc/apt/sources.list
  301. ae6dde92a94e 2 weeks ago /bin/sh -c #(nop) MAINTAINER Solomon Hykes <solomon@dotcloud.com>
  302. ubuntu:12.04 6 months ago
  303. .. _cli_images:
  304. ``images``
  305. ----------
  306. ::
  307. Usage: docker images [OPTIONS] [NAME]
  308. List images
  309. -a=false: show all images (by default filter out the intermediate images used to build)
  310. -notrunc=false: Don't truncate output
  311. -q=false: only show numeric IDs
  312. -tree=false: output graph in tree format
  313. -viz=false: output graph in graphviz format
  314. Listing the most recently created images
  315. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  316. .. code-block:: bash
  317. $ sudo docker images | head
  318. REPOSITORY TAG IMAGE ID CREATED SIZE
  319. <none> <none> 77af4d6b9913 19 hours ago 30.53 MB (virtual 1.089 GB)
  320. committest latest b6fa739cedf5 19 hours ago 30.53 MB (virtual 1.089 GB)
  321. <none> <none> 78a85c484f71 19 hours ago 30.53 MB (virtual 1.089 GB)
  322. docker latest 30557a29d5ab 20 hours ago 30.53 MB (virtual 1.089 GB)
  323. <none> <none> 0124422dd9f9 20 hours ago 30.53 MB (virtual 1.089 GB)
  324. <none> <none> 18ad6fad3402 22 hours ago 23.68 MB (virtual 1.082 GB)
  325. <none> <none> f9f1e26352f0 23 hours ago 30.46 MB (virtual 1.089 GB)
  326. tryout latest 2629d1fa0b81 23 hours ago 16.4 kB (virtual 131.5 MB)
  327. <none> <none> 5ed6274db6ce 24 hours ago 30.44 MB (virtual 1.089 GB)
  328. Listing the full length image IDs
  329. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  330. .. code-block:: bash
  331. $ sudo docker images -notrunc | head
  332. REPOSITORY TAG IMAGE ID CREATED SIZE
  333. <none> <none> 77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 30.53 MB (virtual 1.089 GB)
  334. committest latest b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 30.53 MB (virtual 1.089 GB)
  335. <none> <none> 78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 30.53 MB (virtual 1.089 GB)
  336. docker latest 30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 30.53 MB (virtual 1.089 GB)
  337. <none> <none> 0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 30.53 MB (virtual 1.089 GB)
  338. <none> <none> 18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 23.68 MB (virtual 1.082 GB)
  339. <none> <none> f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 30.46 MB (virtual 1.089 GB)
  340. tryout latest 2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 16.4 kB (virtual 131.5 MB)
  341. <none> <none> 5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 30.44 MB (virtual 1.089 GB)
  342. Displaying images visually
  343. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  344. .. code-block:: bash
  345. $ sudo docker images -viz | dot -Tpng -o docker.png
  346. .. image:: docker_images.gif
  347. :alt: Example inheritance graph of Docker images.
  348. Displaying image hierarchy
  349. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  350. .. code-block:: bash
  351. $ sudo docker images -tree
  352. |─8dbd9e392a96 Size: 131.5 MB (virtual 131.5 MB) Tags: ubuntu:12.04,ubuntu:latest,ubuntu:precise
  353. └─27cf78414709 Size: 180.1 MB (virtual 180.1 MB)
  354. └─b750fe79269d Size: 24.65 kB (virtual 180.1 MB) Tags: ubuntu:12.10,ubuntu:quantal
  355. |─f98de3b610d5 Size: 12.29 kB (virtual 180.1 MB)
  356. | └─7da80deb7dbf Size: 16.38 kB (virtual 180.1 MB)
  357. | └─65ed2fee0a34 Size: 20.66 kB (virtual 180.2 MB)
  358. | └─a2b9ea53dddc Size: 819.7 MB (virtual 999.8 MB)
  359. | └─a29b932eaba8 Size: 28.67 kB (virtual 999.9 MB)
  360. | └─e270a44f124d Size: 12.29 kB (virtual 999.9 MB) Tags: progrium/buildstep:latest
  361. └─17e74ac162d8 Size: 53.93 kB (virtual 180.2 MB)
  362. └─339a3f56b760 Size: 24.65 kB (virtual 180.2 MB)
  363. └─904fcc40e34d Size: 96.7 MB (virtual 276.9 MB)
  364. └─b1b0235328dd Size: 363.3 MB (virtual 640.2 MB)
  365. └─7cb05d1acb3b Size: 20.48 kB (virtual 640.2 MB)
  366. └─47bf6f34832d Size: 20.48 kB (virtual 640.2 MB)
  367. └─f165104e82ed Size: 12.29 kB (virtual 640.2 MB)
  368. └─d9cf85a47b7e Size: 1.911 MB (virtual 642.2 MB)
  369. └─3ee562df86ca Size: 17.07 kB (virtual 642.2 MB)
  370. └─b05fc2d00e4a Size: 24.96 kB (virtual 642.2 MB)
  371. └─c96a99614930 Size: 12.29 kB (virtual 642.2 MB)
  372. └─a6a357a48c49 Size: 12.29 kB (virtual 642.2 MB) Tags: ndj/mongodb:latest
  373. .. _cli_import:
  374. ``import``
  375. ----------
  376. ::
  377. Usage: docker import URL|- [REPOSITORY[:TAG]]
  378. Create a new filesystem image from the contents of a tarball
  379. At this time, the URL must start with ``http`` and point to a single
  380. file archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) containing a
  381. root filesystem. If you would like to import from a local directory or
  382. archive, you can use the ``-`` parameter to take the data from
  383. standard in.
  384. Examples
  385. ~~~~~~~~
  386. Import from a remote location
  387. .............................
  388. This will create a new untagged image.
  389. ``$ sudo docker import http://example.com/exampleimage.tgz``
  390. Import from a local file
  391. ........................
  392. Import to docker via pipe and standard in
  393. ``$ cat exampleimage.tgz | sudo docker import - exampleimagelocal:new``
  394. Import from a local directory
  395. .............................
  396. ``$ sudo tar -c . | docker import - exampleimagedir``
  397. Note the ``sudo`` in this example -- you must preserve the ownership
  398. of the files (especially root ownership) during the archiving with
  399. tar. If you are not root (or sudo) when you tar, then the ownerships
  400. might not get preserved.
  401. .. _cli_info:
  402. ``info``
  403. --------
  404. ::
  405. Usage: docker info
  406. Display system-wide information.
  407. .. code-block:: bash
  408. $ sudo docker info
  409. Containers: 292
  410. Images: 194
  411. Debug mode (server): false
  412. Debug mode (client): false
  413. Fds: 22
  414. Goroutines: 67
  415. LXC Version: 0.9.0
  416. EventsListeners: 115
  417. Kernel Version: 3.8.0-33-generic
  418. WARNING: No swap limit support
  419. .. _cli_insert:
  420. ``insert``
  421. ----------
  422. ::
  423. Usage: docker insert IMAGE URL PATH
  424. Insert a file from URL in the IMAGE at PATH
  425. Examples
  426. ~~~~~~~~
  427. Insert file from github
  428. .......................
  429. .. code-block:: bash
  430. $ sudo docker insert 8283e18b24bc https://raw.github.com/metalivedev/django/master/postinstall /tmp/postinstall.sh
  431. .. _cli_inspect:
  432. ``inspect``
  433. -----------
  434. ::
  435. Usage: docker inspect [OPTIONS] CONTAINER
  436. Return low-level information on a container
  437. .. _cli_kill:
  438. ``kill``
  439. --------
  440. ::
  441. Usage: docker kill CONTAINER [CONTAINER...]
  442. Kill a running container (Send SIGKILL)
  443. The main process inside the container will be sent SIGKILL.
  444. Known Issues (kill)
  445. ~~~~~~~~~~~~~~~~~~~
  446. * :issue:`197` indicates that ``docker kill`` may leave directories
  447. behind and make it difficult to remove the container.
  448. .. _cli_load:
  449. ``load``
  450. --------
  451. ::
  452. Usage: docker load < repository.tar
  453. Loads a tarred repository from the standard input stream.
  454. Restores both images and tags.
  455. .. _cli_login:
  456. ``login``
  457. ---------
  458. ::
  459. Usage: docker login [OPTIONS] [SERVER]
  460. Register or Login to the docker registry server
  461. -e="": email
  462. -p="": password
  463. -u="": username
  464. If you want to login to a private registry you can
  465. specify this by adding the server name.
  466. example:
  467. docker login localhost:8080
  468. .. _cli_logs:
  469. ``logs``
  470. --------
  471. ::
  472. Usage: docker logs [OPTIONS] CONTAINER
  473. Fetch the logs of a container
  474. .. _cli_port:
  475. ``port``
  476. --------
  477. ::
  478. Usage: docker port [OPTIONS] CONTAINER PRIVATE_PORT
  479. Lookup the public-facing port which is NAT-ed to PRIVATE_PORT
  480. .. _cli_ps:
  481. ``ps``
  482. ------
  483. ::
  484. Usage: docker ps [OPTIONS]
  485. List containers
  486. -a=false: Show all containers. Only running containers are shown by default.
  487. -notrunc=false: Don't truncate output
  488. -q=false: Only display numeric IDs
  489. .. _cli_pull:
  490. ``pull``
  491. --------
  492. ::
  493. Usage: docker pull NAME
  494. Pull an image or a repository from the registry
  495. .. _cli_push:
  496. ``push``
  497. --------
  498. ::
  499. Usage: docker push NAME
  500. Push an image or a repository to the registry
  501. .. _cli_restart:
  502. ``restart``
  503. -----------
  504. ::
  505. Usage: docker restart [OPTIONS] NAME
  506. Restart a running container
  507. .. _cli_rm:
  508. ``rm``
  509. ------
  510. ::
  511. Usage: docker rm [OPTIONS] CONTAINER
  512. Remove one or more containers
  513. -link="": Remove the link instead of the actual container
  514. Known Issues (rm)
  515. ~~~~~~~~~~~~~~~~~~~
  516. * :issue:`197` indicates that ``docker kill`` may leave directories
  517. behind and make it difficult to remove the container.
  518. Examples:
  519. ~~~~~~~~~
  520. .. code-block:: bash
  521. $ docker rm /redis
  522. /redis
  523. This will remove the container referenced under the link ``/redis``.
  524. .. code-block:: bash
  525. $ docker rm -link /webapp/redis
  526. /webapp/redis
  527. This will remove the underlying link between ``/webapp`` and the ``/redis`` containers removing all
  528. network communication.
  529. .. code-block:: bash
  530. $ docker rm `docker ps -a -q`
  531. This command will delete all stopped containers. The command ``docker ps -a -q`` will return all
  532. existing container IDs and pass them to the ``rm`` command which will delete them. Any running
  533. containers will not be deleted.
  534. .. _cli_rmi:
  535. ``rmi``
  536. -------
  537. ::
  538. Usage: docker rmi IMAGE [IMAGE...]
  539. Remove one or more images
  540. .. _cli_run:
  541. ``run``
  542. -------
  543. ::
  544. Usage: docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...]
  545. Run a command in a new container
  546. -a=map[]: Attach to stdin, stdout or stderr
  547. -c=0: CPU shares (relative weight)
  548. -cidfile="": Write the container ID to the file
  549. -d=false: Detached mode: Run container in the background, print new container id
  550. -e=[]: Set environment variables
  551. -h="": Container host name
  552. -i=false: Keep stdin open even if not attached
  553. -privileged=false: Give extended privileges to this container
  554. -m="": Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
  555. -n=true: Enable networking for this container
  556. -p=[]: Map a network port to the container
  557. -rm=false: Automatically remove the container when it exits (incompatible with -d)
  558. -t=false: Allocate a pseudo-tty
  559. -u="": Username or UID
  560. -dns=[]: Set custom dns servers for the container
  561. -v=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. If "container-dir" is missing, then docker creates a new volume.
  562. -volumes-from="": Mount all volumes from the given container(s)
  563. -entrypoint="": Overwrite the default entrypoint set by the image
  564. -w="": Working directory inside the container
  565. -lxc-conf=[]: Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"
  566. -sig-proxy=true: Proxify all received signal to the process (even in non-tty mode)
  567. -expose=[]: Expose a port from the container without publishing it to your host
  568. -link="": Add link to another container (name:alias)
  569. -name="": Assign the specified name to the container. If no name is specific docker will generate a random name
  570. -P=false: Publish all exposed ports to the host interfaces
  571. Examples
  572. --------
  573. .. code-block:: bash
  574. sudo docker run -cidfile /tmp/docker_test.cid ubuntu echo "test"
  575. This will create a container and print "test" to the console. The
  576. ``cidfile`` flag makes docker attempt to create a new file and write the
  577. container ID to it. If the file exists already, docker will return an
  578. error. Docker will close this file when docker run exits.
  579. .. code-block:: bash
  580. docker run mount -t tmpfs none /var/spool/squid
  581. This will *not* work, because by default, most potentially dangerous
  582. kernel capabilities are dropped; including ``cap_sys_admin`` (which is
  583. required to mount filesystems). However, the ``-privileged`` flag will
  584. allow it to run:
  585. .. code-block:: bash
  586. docker run -privileged mount -t tmpfs none /var/spool/squid
  587. The ``-privileged`` flag gives *all* capabilities to the container,
  588. and it also lifts all the limitations enforced by the ``device``
  589. cgroup controller. In other words, the container can then do almost
  590. everything that the host can do. This flag exists to allow special
  591. use-cases, like running Docker within Docker.
  592. .. code-block:: bash
  593. docker run -w /path/to/dir/ -i -t ubuntu pwd
  594. The ``-w`` lets the command being executed inside directory given,
  595. here /path/to/dir/. If the path does not exists it is created inside the
  596. container.
  597. .. code-block:: bash
  598. docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
  599. The ``-v`` flag mounts the current working directory into the container.
  600. The ``-w`` lets the command being executed inside the current
  601. working directory, by changing into the directory to the value
  602. returned by ``pwd``. So this combination executes the command
  603. using the container, but inside the current working directory.
  604. .. code-block:: bash
  605. docker run -p 127.0.0.1:80:8080 ubuntu bash
  606. This binds port ``8080`` of the container to port ``80`` on 127.0.0.1 of the
  607. host machine. :ref:`port_redirection` explains in detail how to manipulate ports
  608. in Docker.
  609. .. code-block:: bash
  610. docker run -expose 80 ubuntu bash
  611. This exposes port ``80`` of the container for use within a link without
  612. publishing the port to the host system's interfaces. :ref:`port_redirection`
  613. explains in detail how to manipulate ports in Docker.
  614. .. code-block:: bash
  615. docker run -name console -t -i ubuntu bash
  616. This will create and run a new container with the container name
  617. being ``console``.
  618. .. code-block:: bash
  619. docker run -link /redis:redis -name console ubuntu bash
  620. The ``-link`` flag will link the container named ``/redis`` into the
  621. newly created container with the alias ``redis``. The new container
  622. can access the network and environment of the redis container via
  623. environment variables. The ``-name`` flag will assign the name ``console``
  624. to the newly created container.
  625. .. code-block:: bash
  626. docker run -volumes-from 777f7dc92da7,ba8c0c54f0f2:ro -i -t ubuntu pwd
  627. The ``-volumes-from`` flag mounts all the defined volumes from the
  628. refrence containers. Containers can be specified by a comma seperated
  629. list or by repetitions of the ``-volumes-from`` argument. The container
  630. id may be optionally suffixed with ``:ro`` or ``:rw`` to mount the volumes in
  631. read-only or read-write mode, respectively. By default, the volumes are mounted
  632. in the same mode (rw or ro) as the reference container.
  633. Known Issues (run -volumes-from)
  634. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  635. * :issue:`2702`: "lxc-start: Permission denied - failed to mount"
  636. could indicate a permissions problem with AppArmor. Please see the
  637. issue for a workaround.
  638. .. _cli_save:
  639. ``save``
  640. ::
  641. Usage: docker save image > repository.tar
  642. Streams a tarred repository to the standard output stream.
  643. Contains all parent layers, and all tags + versions.
  644. .. _cli_search:
  645. ``search``
  646. ----------
  647. ::
  648. Usage: docker search TERM
  649. Search the docker index for images
  650. -notrunc=false: Don't truncate output
  651. -stars=0: Only displays with at least xxx stars
  652. -trusted=false: Only show trusted builds
  653. .. _cli_start:
  654. ``start``
  655. ---------
  656. ::
  657. Usage: docker start [OPTIONS] NAME
  658. Start a stopped container
  659. -a=false: Attach container's stdout/stderr and forward all signals to the process
  660. -i=false: Attach container's stdin
  661. .. _cli_stop:
  662. ``stop``
  663. --------
  664. ::
  665. Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
  666. Stop a running container (Send SIGTERM, and then SIGKILL after grace period)
  667. -t=10: Number of seconds to wait for the container to stop before killing it.
  668. The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL
  669. .. _cli_tag:
  670. ``tag``
  671. -------
  672. ::
  673. Usage: docker tag [OPTIONS] IMAGE REPOSITORY[:TAG]
  674. Tag an image into a repository
  675. -f=false: Force
  676. .. _cli_top:
  677. ``top``
  678. -------
  679. ::
  680. Usage: docker top CONTAINER [ps OPTIONS]
  681. Lookup the running processes of a container
  682. .. _cli_version:
  683. ``version``
  684. -----------
  685. Show the version of the docker client, daemon, and latest released version.
  686. .. _cli_wait:
  687. ``wait``
  688. --------
  689. ::
  690. Usage: docker wait [OPTIONS] NAME
  691. Block until a container stops, then print its exit code.