cli.rst 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  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. When host=[0.0.0.0], port=[4243] or path=[/var/run/docker.sock] is omitted, default values are used.
  12. A self-sufficient runtime for linux containers.
  13. ...
  14. .. _cli_daemon:
  15. ``daemon``
  16. ----------
  17. ::
  18. Usage of docker:
  19. -D, --debug=false: Enable debug mode
  20. -H, --host=[]: Multiple tcp://host:port or unix://path/to/socket to bind in daemon mode, single connection otherwise. systemd socket activation can be used with fd://[socketfd].
  21. --api-enable-cors=false: Enable CORS headers in the remote API
  22. -b, --bridge="": Attach containers to a pre-existing network bridge; use 'none' to disable container networking
  23. --bip="": Use this CIDR notation address for the network bridge's IP, not compatible with -b
  24. -d, --daemon=false: Enable daemon mode
  25. --dns=[]: Force docker to use specific DNS servers
  26. -g, --graph="/var/lib/docker": Path to use as the root of the docker runtime
  27. --icc=true: Enable inter-container communication
  28. --ip="0.0.0.0": Default IP address to use when binding container ports
  29. --iptables=true: Disable docker's addition of iptables rules
  30. -p, --pidfile="/var/run/docker.pid": Path to use for daemon PID file
  31. -r, --restart=true: Restart previously running containers
  32. -s, --storage-driver="": Force the docker runtime to use a specific storage driver
  33. -v, --version=false: Print version information and quit
  34. The Docker daemon is the persistent process that manages containers. Docker uses the same binary for both the
  35. daemon and client. To run the daemon you provide the ``-d`` flag.
  36. To force Docker to use devicemapper as the storage driver, use ``docker -d -s devicemapper``.
  37. To set the DNS server for all Docker containers, use ``docker -d -dns 8.8.8.8``.
  38. To run the daemon with debug output, use ``docker -d -D``.
  39. The docker client will also honor the ``DOCKER_HOST`` environment variable to set
  40. the ``-H`` flag for the client.
  41. ::
  42. docker -H tcp://0.0.0.0:4243 ps
  43. # or
  44. export DOCKER_HOST="tcp://0.0.0.0:4243"
  45. docker ps
  46. # both are equal
  47. To run the daemon with `systemd socket activation <http://0pointer.de/blog/projects/socket-activation.html>`_, use ``docker -d -H fd://``.
  48. Using ``fd://`` will work perfectly for most setups but you can also specify individual sockets too ``docker -d -H fd://3``.
  49. If the specified socket activated files aren't found then docker will exit.
  50. You can find examples of using systemd socket activation with docker and systemd in the `docker source tree <https://github.com/dotcloud/docker/blob/master/contrib/init/systemd/socket-activation/>`_.
  51. .. _cli_attach:
  52. ``attach``
  53. ----------
  54. ::
  55. Usage: docker attach CONTAINER
  56. Attach to a running container.
  57. --no-stdin=false: Do not attach stdin
  58. --sig-proxy=true: Proxify all received signal to the process (even in non-tty mode)
  59. You can detach from the container again (and leave it running) with
  60. ``CTRL-c`` (for a quiet exit) or ``CTRL-\`` to get a stacktrace of
  61. the Docker client when it quits. When you detach from the container's
  62. process the exit code will be returned to the client.
  63. To stop a container, use ``docker stop``.
  64. To kill the container, use ``docker kill``.
  65. .. _cli_attach_examples:
  66. Examples:
  67. ~~~~~~~~~
  68. .. code-block:: bash
  69. $ ID=$(sudo docker run -d ubuntu /usr/bin/top -b)
  70. $ sudo docker attach $ID
  71. top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
  72. Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
  73. 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
  74. Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
  75. Swap: 786428k total, 0k used, 786428k free, 221740k cached
  76. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  77. 1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
  78. top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
  79. Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
  80. 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
  81. Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
  82. Swap: 786428k total, 0k used, 786428k free, 221776k cached
  83. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  84. 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
  85. top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05
  86. Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
  87. 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
  88. Mem: 373572k total, 355780k used, 17792k free, 27880k buffers
  89. Swap: 786428k total, 0k used, 786428k free, 221776k cached
  90. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  91. 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
  92. ^C$
  93. $ sudo docker stop $ID
  94. .. _cli_build:
  95. ``build``
  96. ---------
  97. ::
  98. Usage: docker build [OPTIONS] PATH | URL | -
  99. Build a new container image from the source code at PATH
  100. -t, --time="": Repository name (and optionally a tag) to be applied
  101. to the resulting image in case of success.
  102. -q, --quiet=false: Suppress verbose build output.
  103. --no-cache: Do not use the cache when building the image.
  104. --rm: Remove intermediate containers after a successful build
  105. The files at ``PATH`` or ``URL`` are called the "context" of the build. The
  106. build process may refer to any of the files in the context, for example when
  107. using an :ref:`ADD <dockerfile_add>` instruction. When a single ``Dockerfile``
  108. is given as ``URL``, then no context is set. When a Git repository is set as
  109. ``URL``, then the repository is used as the context
  110. .. _cli_build_examples:
  111. .. seealso:: :ref:`dockerbuilder`.
  112. Examples:
  113. ~~~~~~~~~
  114. .. code-block:: bash
  115. $ sudo docker build .
  116. Uploading context 10240 bytes
  117. Step 1 : FROM busybox
  118. Pulling repository busybox
  119. ---> e9aa60c60128MB/2.284 MB (100%) endpoint: https://cdn-registry-1.docker.io/v1/
  120. Step 2 : RUN ls -lh /
  121. ---> Running in 9c9e81692ae9
  122. total 24
  123. drwxr-xr-x 2 root root 4.0K Mar 12 2013 bin
  124. drwxr-xr-x 5 root root 4.0K Oct 19 00:19 dev
  125. drwxr-xr-x 2 root root 4.0K Oct 19 00:19 etc
  126. drwxr-xr-x 2 root root 4.0K Nov 15 23:34 lib
  127. lrwxrwxrwx 1 root root 3 Mar 12 2013 lib64 -> lib
  128. dr-xr-xr-x 116 root root 0 Nov 15 23:34 proc
  129. lrwxrwxrwx 1 root root 3 Mar 12 2013 sbin -> bin
  130. dr-xr-xr-x 13 root root 0 Nov 15 23:34 sys
  131. drwxr-xr-x 2 root root 4.0K Mar 12 2013 tmp
  132. drwxr-xr-x 2 root root 4.0K Nov 15 23:34 usr
  133. ---> b35f4035db3f
  134. Step 3 : CMD echo Hello World
  135. ---> Running in 02071fceb21b
  136. ---> f52f38b7823e
  137. Successfully built f52f38b7823e
  138. This example specifies that the ``PATH`` is ``.``, and so all the files in
  139. the local directory get tar'd and sent to the Docker daemon. The ``PATH``
  140. specifies where to find the files for the "context" of the build on
  141. the Docker daemon. Remember that the daemon could be running on a
  142. remote machine and that no parsing of the ``Dockerfile`` happens at the
  143. client side (where you're running ``docker build``). That means that
  144. *all* the files at ``PATH`` get sent, not just the ones listed to
  145. :ref:`ADD <dockerfile_add>` in the ``Dockerfile``.
  146. The transfer of context from the local machine to the Docker daemon is
  147. what the ``docker`` client means when you see the "Uploading context"
  148. message.
  149. .. code-block:: bash
  150. $ sudo docker build -t vieux/apache:2.0 .
  151. This will build like the previous example, but it will then tag the
  152. resulting image. The repository name will be ``vieux/apache`` and the
  153. tag will be ``2.0``
  154. .. code-block:: bash
  155. $ sudo docker build - < Dockerfile
  156. This will read a ``Dockerfile`` from *stdin* without context. Due to
  157. the lack of a context, no contents of any local directory will be sent
  158. to the ``docker`` daemon. Since there is no context, a ``Dockerfile``
  159. ``ADD`` only works if it refers to a remote URL.
  160. .. code-block:: bash
  161. $ sudo docker build github.com/creack/docker-firefox
  162. This will clone the GitHub repository and use the cloned repository as
  163. context. The ``Dockerfile`` at the root of the repository is used as
  164. ``Dockerfile``. Note that you can specify an arbitrary Git repository
  165. by using the ``git://`` schema.
  166. .. _cli_commit:
  167. ``commit``
  168. ----------
  169. ::
  170. Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
  171. Create a new image from a container's changes
  172. -m, --message="": Commit message
  173. -a, --author="": Author (eg. "John Hannibal Smith <hannibal@a-team.com>"
  174. --run="": Configuration to be applied when the image is launched with `docker run`.
  175. (ex: -run='{"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')
  176. .. _cli_commit_examples:
  177. Commit an existing container
  178. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179. .. code-block:: bash
  180. $ sudo docker ps
  181. ID IMAGE COMMAND CREATED STATUS PORTS
  182. c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
  183. 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
  184. $ docker commit c3f279d17e0a SvenDowideit/testimage:version3
  185. f5283438590d
  186. $ docker images | head
  187. REPOSITORY TAG ID CREATED VIRTUAL SIZE
  188. SvenDowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB
  189. Change the command that a container runs
  190. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  191. Sometimes you have an application container running just a service and you need
  192. to make a quick change and then change it back.
  193. In this example, we run a container with ``ls`` and then change the image to
  194. run ``ls /etc``.
  195. .. code-block:: bash
  196. $ docker run -t -name test ubuntu ls
  197. bin boot dev etc home lib lib64 media mnt opt proc root run sbin selinux srv sys tmp usr var
  198. $ docker commit -run='{"Cmd": ["ls","/etc"]}' test test2
  199. 933d16de9e70005304c1717b5c6f2f39d6fd50752834c6f34a155c70790011eb
  200. $ docker run -t test2
  201. adduser.conf gshadow login.defs rc0.d
  202. alternatives gshadow- logrotate.d rc1.d
  203. apt host.conf lsb-base rc2.d
  204. ...
  205. Full -run example
  206. .................
  207. The ``--run`` JSON hash changes the ``Config`` section when running ``docker inspect CONTAINERID``
  208. or ``config`` when running ``docker inspect IMAGEID``.
  209. (Multiline is okay within a single quote ``'``)
  210. .. code-block:: bash
  211. $ sudo docker commit -run='
  212. {
  213. "Entrypoint" : null,
  214. "Privileged" : false,
  215. "User" : "",
  216. "VolumesFrom" : "",
  217. "Cmd" : ["cat", "-e", "/etc/resolv.conf"],
  218. "Dns" : ["8.8.8.8", "8.8.4.4"],
  219. "MemorySwap" : 0,
  220. "AttachStdin" : false,
  221. "AttachStderr" : false,
  222. "CpuShares" : 0,
  223. "OpenStdin" : false,
  224. "Volumes" : null,
  225. "Hostname" : "122612f45831",
  226. "PortSpecs" : ["22", "80", "443"],
  227. "Image" : "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  228. "Tty" : false,
  229. "Env" : [
  230. "HOME=/",
  231. "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  232. ],
  233. "StdinOnce" : false,
  234. "Domainname" : "",
  235. "WorkingDir" : "/",
  236. "NetworkDisabled" : false,
  237. "Memory" : 0,
  238. "AttachStdout" : false
  239. }' $CONTAINER_ID
  240. .. _cli_cp:
  241. ``cp``
  242. ------
  243. ::
  244. Usage: docker cp CONTAINER:PATH HOSTPATH
  245. Copy files/folders from the containers filesystem to the host
  246. path. Paths are relative to the root of the filesystem.
  247. .. code-block:: bash
  248. $ sudo docker cp 7bb0e258aefe:/etc/debian_version .
  249. $ sudo docker cp blue_frog:/etc/hosts .
  250. .. _cli_diff:
  251. ``diff``
  252. --------
  253. ::
  254. Usage: docker diff CONTAINER
  255. List the changed files and directories in a container's filesystem
  256. There are 3 events that are listed in the 'diff':
  257. 1. ```A``` - Add
  258. 2. ```D``` - Delete
  259. 3. ```C``` - Change
  260. For example:
  261. .. code-block:: bash
  262. $ sudo docker diff 7bb0e258aefe
  263. C /dev
  264. A /dev/kmsg
  265. C /etc
  266. A /etc/mtab
  267. A /go
  268. A /go/src
  269. A /go/src/github.com
  270. A /go/src/github.com/dotcloud
  271. A /go/src/github.com/dotcloud/docker
  272. A /go/src/github.com/dotcloud/docker/.git
  273. ....
  274. .. _cli_events:
  275. ``events``
  276. ----------
  277. ::
  278. Usage: docker events
  279. Get real time events from the server
  280. --since="": Show previously created events and then stream.
  281. (either seconds since epoch, or date string as below)
  282. .. _cli_events_example:
  283. Examples
  284. ~~~~~~~~
  285. You'll need two shells for this example.
  286. Shell 1: Listening for events
  287. .............................
  288. .. code-block:: bash
  289. $ sudo docker events
  290. Shell 2: Start and Stop a Container
  291. ...................................
  292. .. code-block:: bash
  293. $ sudo docker start 4386fb97867d
  294. $ sudo docker stop 4386fb97867d
  295. Shell 1: (Again .. now showing events)
  296. ......................................
  297. .. code-block:: bash
  298. [2013-09-03 15:49:26 +0200 CEST] 4386fb97867d: (from 12de384bfb10) start
  299. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
  300. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
  301. Show events in the past from a specified time
  302. .............................................
  303. .. code-block:: bash
  304. $ sudo docker events -since 1378216169
  305. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
  306. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
  307. $ sudo docker events -since '2013-09-03'
  308. [2013-09-03 15:49:26 +0200 CEST] 4386fb97867d: (from 12de384bfb10) start
  309. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
  310. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
  311. $ sudo docker events -since '2013-09-03 15:49:29 +0200 CEST'
  312. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
  313. [2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
  314. .. _cli_export:
  315. ``export``
  316. ----------
  317. ::
  318. Usage: docker export CONTAINER
  319. Export the contents of a filesystem as a tar archive to STDOUT
  320. For example:
  321. .. code-block:: bash
  322. $ sudo docker export red_panda > latest.tar
  323. .. _cli_history:
  324. ``history``
  325. -----------
  326. ::
  327. Usage: docker history [OPTIONS] IMAGE
  328. Show the history of an image
  329. --no-trunc=false: Don't truncate output
  330. -q, --quiet=false: only show numeric IDs
  331. To see how the ``docker:latest`` image was built:
  332. .. code-block:: bash
  333. $ docker history docker
  334. ID CREATED CREATED BY
  335. docker:latest 19 hours ago /bin/sh -c #(nop) ADD . in /go/src/github.com/dotcloud/docker
  336. cf5f2467662d 2 weeks ago /bin/sh -c #(nop) ENTRYPOINT ["hack/dind"]
  337. 3538fbe372bf 2 weeks ago /bin/sh -c #(nop) WORKDIR /go/src/github.com/dotcloud/docker
  338. 7450f65072e5 2 weeks ago /bin/sh -c #(nop) VOLUME /var/lib/docker
  339. b79d62b97328 2 weeks ago /bin/sh -c apt-get install -y -q lxc
  340. 36714852a550 2 weeks ago /bin/sh -c apt-get install -y -q iptables
  341. 8c4c706df1d6 2 weeks ago /bin/sh -c /bin/echo -e '[default]\naccess_key=$AWS_ACCESS_KEY\nsecret_key=$AWS_SECRET_KEYn' > /.s3cfg
  342. b89989433c48 2 weeks ago /bin/sh -c pip install python-magic
  343. a23e640d85b5 2 weeks ago /bin/sh -c pip install s3cmd
  344. 41f54fec7e79 2 weeks ago /bin/sh -c apt-get install -y -q python-pip
  345. d9bc04add907 2 weeks ago /bin/sh -c apt-get install -y -q reprepro dpkg-sig
  346. e74f4760fa70 2 weeks ago /bin/sh -c gem install --no-rdoc --no-ri fpm
  347. 1e43224726eb 2 weeks ago /bin/sh -c apt-get install -y -q ruby1.9.3 rubygems libffi-dev
  348. 460953ae9d7f 2 weeks ago /bin/sh -c #(nop) ENV GOPATH=/go:/go/src/github.com/dotcloud/docker/vendor
  349. 8b63eb1d666b 2 weeks ago /bin/sh -c #(nop) ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/goroot/bin
  350. 3087f3bcedf2 2 weeks ago /bin/sh -c #(nop) ENV GOROOT=/goroot
  351. 635840d198e5 2 weeks ago /bin/sh -c cd /goroot/src && ./make.bash
  352. 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
  353. 13967ed36e93 2 weeks ago /bin/sh -c #(nop) ENV CGO_ENABLED=0
  354. bf7424458437 2 weeks ago /bin/sh -c apt-get install -y -q build-essential
  355. a89ec997c3bf 2 weeks ago /bin/sh -c apt-get install -y -q mercurial
  356. b9f165c6e749 2 weeks ago /bin/sh -c apt-get install -y -q git
  357. 17a64374afa7 2 weeks ago /bin/sh -c apt-get install -y -q curl
  358. d5e85dc5b1d8 2 weeks ago /bin/sh -c apt-get update
  359. 13e642467c11 2 weeks ago /bin/sh -c echo 'deb http://archive.ubuntu.com/ubuntu precise main universe' > /etc/apt/sources.list
  360. ae6dde92a94e 2 weeks ago /bin/sh -c #(nop) MAINTAINER Solomon Hykes <solomon@dotcloud.com>
  361. ubuntu:12.04 6 months ago
  362. .. _cli_images:
  363. ``images``
  364. ----------
  365. ::
  366. Usage: docker images [OPTIONS] [NAME]
  367. List images
  368. -a, --all=false: show all images (by default filter out the intermediate images used to build)
  369. --no-trunc=false: Don't truncate output
  370. -q, --quiet=false: only show numeric IDs
  371. --tree=false: output graph in tree format
  372. --viz=false: output graph in graphviz format
  373. Listing the most recently created images
  374. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  375. .. code-block:: bash
  376. $ sudo docker images | head
  377. REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
  378. <none> <none> 77af4d6b9913 19 hours ago 1.089 GB
  379. committest latest b6fa739cedf5 19 hours ago 1.089 GB
  380. <none> <none> 78a85c484f71 19 hours ago 1.089 GB
  381. docker latest 30557a29d5ab 20 hours ago 1.089 GB
  382. <none> <none> 0124422dd9f9 20 hours ago 1.089 GB
  383. <none> <none> 18ad6fad3402 22 hours ago 1.082 GB
  384. <none> <none> f9f1e26352f0 23 hours ago 1.089 GB
  385. tryout latest 2629d1fa0b81 23 hours ago 131.5 MB
  386. <none> <none> 5ed6274db6ce 24 hours ago 1.089 GB
  387. Listing the full length image IDs
  388. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  389. .. code-block:: bash
  390. $ sudo docker images --no-trunc | head
  391. REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
  392. <none> <none> 77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB
  393. committest latest b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB
  394. <none> <none> 78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB
  395. docker latest 30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB
  396. <none> <none> 0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB
  397. <none> <none> 18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB
  398. <none> <none> f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB
  399. tryout latest 2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 131.5 MB
  400. <none> <none> 5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB
  401. Displaying images visually
  402. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  403. .. code-block:: bash
  404. $ sudo docker images --viz | dot -Tpng -o docker.png
  405. .. image:: docker_images.gif
  406. :alt: Example inheritance graph of Docker images.
  407. Displaying image hierarchy
  408. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  409. .. code-block:: bash
  410. $ sudo docker images --tree
  411. ├─8dbd9e392a96 Size: 131.5 MB (virtual 131.5 MB) Tags: ubuntu:12.04,ubuntu:latest,ubuntu:precise
  412. └─27cf78414709 Size: 180.1 MB (virtual 180.1 MB)
  413. └─b750fe79269d Size: 24.65 kB (virtual 180.1 MB) Tags: ubuntu:12.10,ubuntu:quantal
  414. ├─f98de3b610d5 Size: 12.29 kB (virtual 180.1 MB)
  415. │ └─7da80deb7dbf Size: 16.38 kB (virtual 180.1 MB)
  416. │ └─65ed2fee0a34 Size: 20.66 kB (virtual 180.2 MB)
  417. │ └─a2b9ea53dddc Size: 819.7 MB (virtual 999.8 MB)
  418. │ └─a29b932eaba8 Size: 28.67 kB (virtual 999.9 MB)
  419. │ └─e270a44f124d Size: 12.29 kB (virtual 999.9 MB) Tags: progrium/buildstep:latest
  420. └─17e74ac162d8 Size: 53.93 kB (virtual 180.2 MB)
  421. └─339a3f56b760 Size: 24.65 kB (virtual 180.2 MB)
  422. └─904fcc40e34d Size: 96.7 MB (virtual 276.9 MB)
  423. └─b1b0235328dd Size: 363.3 MB (virtual 640.2 MB)
  424. └─7cb05d1acb3b Size: 20.48 kB (virtual 640.2 MB)
  425. └─47bf6f34832d Size: 20.48 kB (virtual 640.2 MB)
  426. └─f165104e82ed Size: 12.29 kB (virtual 640.2 MB)
  427. └─d9cf85a47b7e Size: 1.911 MB (virtual 642.2 MB)
  428. └─3ee562df86ca Size: 17.07 kB (virtual 642.2 MB)
  429. └─b05fc2d00e4a Size: 24.96 kB (virtual 642.2 MB)
  430. └─c96a99614930 Size: 12.29 kB (virtual 642.2 MB)
  431. └─a6a357a48c49 Size: 12.29 kB (virtual 642.2 MB) Tags: ndj/mongodb:latest
  432. .. _cli_import:
  433. ``import``
  434. ----------
  435. ::
  436. Usage: docker import URL|- [REPOSITORY[:TAG]]
  437. Create an empty filesystem image and import the contents of the tarball
  438. (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then optionally tag it.
  439. At this time, the URL must start with ``http`` and point to a single
  440. file archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, or .txz) containing a
  441. root filesystem. If you would like to import from a local directory or
  442. archive, you can use the ``-`` parameter to take the data from *stdin*.
  443. Examples
  444. ~~~~~~~~
  445. Import from a remote location
  446. .............................
  447. This will create a new untagged image.
  448. .. code-block:: bash
  449. $ sudo docker import http://example.com/exampleimage.tgz
  450. Import from a local file
  451. ........................
  452. Import to docker via pipe and *stdin*.
  453. .. code-block:: bash
  454. $ cat exampleimage.tgz | sudo docker import - exampleimagelocal:new
  455. Import from a local directory
  456. .............................
  457. .. code-block:: bash
  458. $ sudo tar -c . | docker import - exampleimagedir
  459. Note the ``sudo`` in this example -- you must preserve the ownership of the
  460. files (especially root ownership) during the archiving with tar. If you are not
  461. root (or the sudo command) when you tar, then the ownerships might not get
  462. preserved.
  463. .. _cli_info:
  464. ``info``
  465. --------
  466. ::
  467. Usage: docker info
  468. Display system-wide information.
  469. .. code-block:: bash
  470. $ sudo docker info
  471. Containers: 292
  472. Images: 194
  473. Debug mode (server): false
  474. Debug mode (client): false
  475. Fds: 22
  476. Goroutines: 67
  477. LXC Version: 0.9.0
  478. EventsListeners: 115
  479. Kernel Version: 3.8.0-33-generic
  480. WARNING: No swap limit support
  481. .. _cli_insert:
  482. ``insert``
  483. ----------
  484. ::
  485. Usage: docker insert IMAGE URL PATH
  486. Insert a file from URL in the IMAGE at PATH
  487. Use the specified ``IMAGE`` as the parent for a new image which adds a
  488. :ref:`layer <layer_def>` containing the new file. The ``insert`` command does
  489. not modify the original image, and the new image has the contents of the parent
  490. image, plus the new file.
  491. Examples
  492. ~~~~~~~~
  493. Insert file from GitHub
  494. .......................
  495. .. code-block:: bash
  496. $ sudo docker insert 8283e18b24bc https://raw.github.com/metalivedev/django/master/postinstall /tmp/postinstall.sh
  497. 06fd35556d7b
  498. .. _cli_inspect:
  499. ``inspect``
  500. -----------
  501. ::
  502. Usage: docker inspect CONTAINER|IMAGE [CONTAINER|IMAGE...]
  503. Return low-level information on a container/image
  504. -f, --format="": Format the output using the given go template.
  505. By default, this will render all results in a JSON array. If a format
  506. is specified, the given template will be executed for each result.
  507. Go's `text/template <http://golang.org/pkg/text/template/>`_ package
  508. describes all the details of the format.
  509. Examples
  510. ~~~~~~~~
  511. Get an instance's IP Address
  512. ............................
  513. For the most part, you can pick out any field from the JSON in a
  514. fairly straightforward manner.
  515. .. code-block:: bash
  516. $ sudo docker inspect --format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID
  517. List All Port Bindings
  518. ......................
  519. One can loop over arrays and maps in the results to produce simple
  520. text output:
  521. .. code-block:: bash
  522. $ sudo docker inspect -format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
  523. Find a Specific Port Mapping
  524. ............................
  525. The ``.Field`` syntax doesn't work when the field name begins with a
  526. number, but the template language's ``index`` function does. The
  527. ``.NetworkSettings.Ports`` section contains a map of the internal port
  528. mappings to a list of external address/port objects, so to grab just
  529. the numeric public port, you use ``index`` to find the specific port
  530. map, and then ``index`` 0 contains first object inside of that. Then
  531. we ask for the ``HostPort`` field to get the public address.
  532. .. code-block:: bash
  533. $ sudo docker inspect -format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
  534. .. _cli_kill:
  535. ``kill``
  536. --------
  537. ::
  538. Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...]
  539. Kill a running container (send SIGKILL, or specified signal)
  540. -s, --signal="KILL": Signal to send to the container
  541. The main process inside the container will be sent SIGKILL, or any signal specified with option ``--signal``.
  542. Known Issues (kill)
  543. ~~~~~~~~~~~~~~~~~~~
  544. * :issue:`197` indicates that ``docker kill`` may leave directories
  545. behind and make it difficult to remove the container.
  546. .. _cli_load:
  547. ``load``
  548. --------
  549. ::
  550. Usage: docker load < repository.tar
  551. Loads a tarred repository from the standard input stream.
  552. Restores both images and tags.
  553. .. _cli_login:
  554. ``login``
  555. ---------
  556. ::
  557. Usage: docker login [OPTIONS] [SERVER]
  558. Register or Login to the docker registry server
  559. -e, --email="": email
  560. -p, --password="": password
  561. -u, --username="": username
  562. If you want to login to a private registry you can
  563. specify this by adding the server name.
  564. example:
  565. docker login localhost:8080
  566. .. _cli_logs:
  567. ``logs``
  568. --------
  569. ::
  570. Usage: docker logs [OPTIONS] CONTAINER
  571. Fetch the logs of a container
  572. -f, --follow=false: Follow log output
  573. The ``docker logs`` command is a convenience which batch-retrieves whatever
  574. logs are present at the time of execution. This does not guarantee execution
  575. order when combined with a ``docker run`` (i.e. your run may not have generated
  576. any logs at the time you execute ``docker logs``).
  577. The ``docker logs --follow`` command combines ``docker logs`` and ``docker attach``:
  578. it will first return all logs from the beginning and then continue streaming
  579. new output from the container's stdout and stderr.
  580. .. _cli_port:
  581. ``port``
  582. --------
  583. ::
  584. Usage: docker port [OPTIONS] CONTAINER PRIVATE_PORT
  585. Lookup the public-facing port which is NAT-ed to PRIVATE_PORT
  586. .. _cli_ps:
  587. ``ps``
  588. ------
  589. ::
  590. Usage: docker ps [OPTIONS]
  591. List containers
  592. -a, --all=false: Show all containers. Only running containers are shown by default.
  593. --no-trunc=false: Don't truncate output
  594. -q, --quiet=false: Only display numeric IDs
  595. Running ``docker ps`` showing 2 linked containers.
  596. .. code-block:: bash
  597. $ docker ps
  598. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  599. 4c01db0b339c ubuntu:12.04 bash 17 seconds ago Up 16 seconds webapp
  600. d7886598dbe2 crosbymichael/redis:latest /redis-server --dir 33 minutes ago Up 33 minutes 6379/tcp redis,webapp/db
  601. fd2645e2e2b5 busybox:latest top 10 days ago Ghost insane_ptolemy
  602. The last container is marked as a ``Ghost`` container. It is a container that was running when the docker daemon was restarted (upgraded, or ``-H`` settings changed). The container is still running, but as this docker daemon process is not able to manage it, you can't attach to it. To bring them out of ``Ghost`` Status, you need to use ``docker kill`` or ``docker restart``.
  603. .. _cli_pull:
  604. ``pull``
  605. --------
  606. ::
  607. Usage: docker pull NAME
  608. Pull an image or a repository from the registry
  609. .. _cli_push:
  610. ``push``
  611. --------
  612. ::
  613. Usage: docker push NAME
  614. Push an image or a repository to the registry
  615. .. _cli_restart:
  616. ``restart``
  617. -----------
  618. ::
  619. Usage: docker restart [OPTIONS] NAME
  620. Restart a running container
  621. .. _cli_rm:
  622. ``rm``
  623. ------
  624. ::
  625. Usage: docker rm [OPTIONS] CONTAINER
  626. Remove one or more containers
  627. --link="": Remove the link instead of the actual container
  628. Known Issues (rm)
  629. ~~~~~~~~~~~~~~~~~
  630. * :issue:`197` indicates that ``docker kill`` may leave directories
  631. behind and make it difficult to remove the container.
  632. Examples:
  633. ~~~~~~~~~
  634. .. code-block:: bash
  635. $ sudo docker rm /redis
  636. /redis
  637. This will remove the container referenced under the link ``/redis``.
  638. .. code-block:: bash
  639. $ sudo docker rm --link /webapp/redis
  640. /webapp/redis
  641. This will remove the underlying link between ``/webapp`` and the ``/redis`` containers removing all
  642. network communication.
  643. .. code-block:: bash
  644. $ sudo docker rm `docker ps -a -q`
  645. This command will delete all stopped containers. The command ``docker ps -a -q`` will return all
  646. existing container IDs and pass them to the ``rm`` command which will delete them. Any running
  647. containers will not be deleted.
  648. .. _cli_rmi:
  649. ``rmi``
  650. -------
  651. ::
  652. Usage: docker rmi IMAGE [IMAGE...]
  653. Remove one or more images
  654. Removing tagged images
  655. ~~~~~~~~~~~~~~~~~~~~~~
  656. Images can be removed either by their short or long ID's, or their image names.
  657. If an image has more than one name, each of them needs to be removed before the
  658. image is removed.
  659. .. code-block:: bash
  660. $ sudo docker images
  661. REPOSITORY TAG IMAGE ID CREATED SIZE
  662. test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
  663. test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
  664. test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
  665. $ sudo docker rmi fd484f19954f
  666. Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories
  667. 2013/12/11 05:47:16 Error: failed to remove one or more images
  668. $ sudo docker rmi test1
  669. Untagged: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  670. $ sudo docker rmi test2
  671. Untagged: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  672. $ sudo docker images
  673. REPOSITORY TAG IMAGE ID CREATED SIZE
  674. test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
  675. $ sudo docker rmi test
  676. Untagged: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  677. Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  678. .. _cli_run:
  679. ``run``
  680. -------
  681. ::
  682. Usage: docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...]
  683. Run a command in a new container
  684. -a, --attach=map[]: Attach to stdin, stdout or stderr
  685. -c, --cpu-shares=0: CPU shares (relative weight)
  686. --cidfile="": Write the container ID to the file
  687. -d, --detach=false: Detached mode: Run container in the background, print new container id
  688. -e, --env=[]: Set environment variables
  689. -h, --host="": Container host name
  690. -i, --interactive=false: Keep stdin open even if not attached
  691. --privileged=false: Give extended privileges to this container
  692. -m, --memory="": Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
  693. -n, --networking=true: Enable networking for this container
  694. -p, --publish=[]: Map a network port to the container
  695. --rm=false: Automatically remove the container when it exits (incompatible with -d)
  696. -t, --tty=false: Allocate a pseudo-tty
  697. -u, --user="": Username or UID
  698. --dns=[]: Set custom dns servers for the container
  699. -v, --volume=[]: Create a bind mount to a directory or file with: [host-path]:[container-path]:[rw|ro]. If a directory "container-path" is missing, then docker creates a new volume.
  700. --volumes-from="": Mount all volumes from the given container(s)
  701. --entrypoint="": Overwrite the default entrypoint set by the image
  702. -w, --workdir="": Working directory inside the container
  703. --lxc-conf=[]: Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"
  704. --sig-proxy=true: Proxify all received signal to the process (even in non-tty mode)
  705. --expose=[]: Expose a port from the container without publishing it to your host
  706. --link="": Add link to another container (name:alias)
  707. --name="": Assign the specified name to the container. If no name is specific docker will generate a random name
  708. -P, --publish-all=false: Publish all exposed ports to the host interfaces
  709. The ``docker run`` command first ``creates`` a writeable container layer over
  710. the specified image, and then ``starts`` it using the specified command. That
  711. is, ``docker run`` is equivalent to the API ``/containers/create`` then
  712. ``/containers/(id)/start``.
  713. The ``docker run`` command can be used in combination with ``docker commit`` to
  714. :ref:`change the command that a container runs <cli_commit_examples>`.
  715. Known Issues (run -volumes-from)
  716. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  717. * :issue:`2702`: "lxc-start: Permission denied - failed to mount"
  718. could indicate a permissions problem with AppArmor. Please see the
  719. issue for a workaround.
  720. Examples:
  721. ~~~~~~~~~
  722. .. code-block:: bash
  723. $ sudo docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
  724. This will create a container and print ``test`` to the console. The
  725. ``cidfile`` flag makes Docker attempt to create a new file and write the
  726. container ID to it. If the file exists already, Docker will return an
  727. error. Docker will close this file when ``docker run`` exits.
  728. .. code-block:: bash
  729. $ sudo docker run -t -i --rm ubuntu bash
  730. root@bc338942ef20:/# mount -t tmpfs none /mnt
  731. mount: permission denied
  732. This will *not* work, because by default, most potentially dangerous
  733. kernel capabilities are dropped; including ``cap_sys_admin`` (which is
  734. required to mount filesystems). However, the ``-privileged`` flag will
  735. allow it to run:
  736. .. code-block:: bash
  737. $ sudo docker run --privileged ubuntu bash
  738. root@50e3f57e16e6:/# mount -t tmpfs none /mnt
  739. root@50e3f57e16e6:/# df -h
  740. Filesystem Size Used Avail Use% Mounted on
  741. none 1.9G 0 1.9G 0% /mnt
  742. The ``-privileged`` flag gives *all* capabilities to the container,
  743. and it also lifts all the limitations enforced by the ``device``
  744. cgroup controller. In other words, the container can then do almost
  745. everything that the host can do. This flag exists to allow special
  746. use-cases, like running Docker within Docker.
  747. .. code-block:: bash
  748. $ sudo docker run -w /path/to/dir/ -i -t ubuntu pwd
  749. The ``-w`` lets the command being executed inside directory given,
  750. here ``/path/to/dir/``. If the path does not exists it is created inside the
  751. container.
  752. .. code-block:: bash
  753. $ sudo docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
  754. The ``-v`` flag mounts the current working directory into the container.
  755. The ``-w`` lets the command being executed inside the current
  756. working directory, by changing into the directory to the value
  757. returned by ``pwd``. So this combination executes the command
  758. using the container, but inside the current working directory.
  759. .. code-block:: bash
  760. $ sudo docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash
  761. When the host directory of a bind-mounted volume doesn't exist, Docker
  762. will automatically create this directory on the host for you. In the
  763. example above, Docker will create the ``/doesnt/exist`` folder before
  764. starting your container.
  765. .. code-block:: bash
  766. $ sudo docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v ./static-docker:/usr/bin/docker busybox sh
  767. By bind-mounting the docker unix socket and statically linked docker binary
  768. (such as that provided by https://get.docker.io), you give the container
  769. the full access to create and manipulate the host's docker daemon.
  770. .. code-block:: bash
  771. $ sudo docker run -p 127.0.0.1:80:8080 ubuntu bash
  772. This binds port ``8080`` of the container to port ``80`` on ``127.0.0.1`` of the
  773. host machine. :ref:`port_redirection` explains in detail how to manipulate ports
  774. in Docker.
  775. .. code-block:: bash
  776. $ sudo docker run --expose 80 ubuntu bash
  777. This exposes port ``80`` of the container for use within a link without
  778. publishing the port to the host system's interfaces. :ref:`port_redirection`
  779. explains in detail how to manipulate ports in Docker.
  780. .. code-block:: bash
  781. $ sudo docker run --name console -t -i ubuntu bash
  782. This will create and run a new container with the container name
  783. being ``console``.
  784. .. code-block:: bash
  785. $ sudo docker run --link /redis:redis --name console ubuntu bash
  786. The ``--link`` flag will link the container named ``/redis`` into the
  787. newly created container with the alias ``redis``. The new container
  788. can access the network and environment of the redis container via
  789. environment variables. The ``--name`` flag will assign the name ``console``
  790. to the newly created container.
  791. .. code-block:: bash
  792. $ sudo docker run --volumes-from 777f7dc92da7,ba8c0c54f0f2:ro -i -t ubuntu pwd
  793. The ``--volumes-from`` flag mounts all the defined volumes from the
  794. referenced containers. Containers can be specified by a comma seperated
  795. list or by repetitions of the ``--volumes-from`` argument. The container
  796. ID may be optionally suffixed with ``:ro`` or ``:rw`` to mount the volumes in
  797. read-only or read-write mode, respectively. By default, the volumes are mounted
  798. in the same mode (read write or read only) as the reference container.
  799. A complete example
  800. ..................
  801. .. code-block:: bash
  802. $ sudo docker run -d --name static static-web-files sh
  803. $ sudo docker run -d --expose=8098 --name riak riakserver
  804. $ sudo docker run -d -m 100m -e DEVELOPMENT=1 -e BRANCH=example-code -v $(pwd):/app/bin:ro --name app appserver
  805. $ sudo docker run -d -p 1443:443 --dns=dns.dev.org -v /var/log/httpd --volumes-from static --link riak --link app -h www.sven.dev.org --name web webserver
  806. $ sudo docker run -t -i --rm --volumes-from web -w /var/log/httpd busybox tail -f access.log
  807. This example shows 5 containers that might be set up to test a web application change:
  808. 1. Start a pre-prepared volume image ``static-web-files`` (in the background) that has CSS, image and static HTML in it, (with a ``VOLUME`` instruction in the ``Dockerfile`` to allow the web server to use those files);
  809. 2. Start a pre-prepared ``riakserver`` image, give the container name ``riak`` and expose port ``8098`` to any containers that link to it;
  810. 3. Start the ``appserver`` image, restricting its memory usage to 100MB, setting two environment variables ``DEVELOPMENT`` and ``BRANCH`` and bind-mounting the current directory (``$(pwd)``) in the container in read-only mode as ``/app/bin``;
  811. 4. Start the ``webserver``, mapping port ``443`` in the container to port ``1443`` on the Docker server, setting the DNS server to ``dns.dev.org``, creating a volume to put the log files into (so we can access it from another container), then importing the files from the volume exposed by the ``static`` container, and linking to all exposed ports from ``riak`` and ``app``. Lastly, we set the hostname to ``web.sven.dev.org`` so its consistent with the pre-generated SSL certificate;
  812. 5. Finally, we create a container that runs ``tail -f access.log`` using the logs volume from the ``web`` container, setting the workdir to ``/var/log/httpd``. The ``-rm`` option means that when the container exits, the container's layer is removed.
  813. .. _cli_save:
  814. ``save``
  815. ---------
  816. ::
  817. Usage: docker save image > repository.tar
  818. Streams a tarred repository to the standard output stream.
  819. Contains all parent layers, and all tags + versions.
  820. .. _cli_search:
  821. ``search``
  822. ----------
  823. ::
  824. Usage: docker search TERM
  825. Search the docker index for images
  826. --no-trunc=false: Don't truncate output
  827. -s, --stars=0: Only displays with at least xxx stars
  828. -t, --trusted=false: Only show trusted builds
  829. .. _cli_start:
  830. ``start``
  831. ---------
  832. ::
  833. Usage: docker start [OPTIONS] CONTAINER
  834. Start a stopped container
  835. -a, --attach=false: Attach container's stdout/stderr and forward all signals to the process
  836. -i, --interactive=false: Attach container's stdin
  837. .. _cli_stop:
  838. ``stop``
  839. --------
  840. ::
  841. Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
  842. Stop a running container (Send SIGTERM, and then SIGKILL after grace period)
  843. -t, --time=10: Number of seconds to wait for the container to stop before killing it.
  844. The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL
  845. .. _cli_tag:
  846. ``tag``
  847. -------
  848. ::
  849. Usage: docker tag [OPTIONS] IMAGE REPOSITORY[:TAG]
  850. Tag an image into a repository
  851. -f, --force=false: Force
  852. .. _cli_top:
  853. ``top``
  854. -------
  855. ::
  856. Usage: docker top CONTAINER [ps OPTIONS]
  857. Lookup the running processes of a container
  858. .. _cli_version:
  859. ``version``
  860. -----------
  861. Show the version of the Docker client, daemon, and latest released version.
  862. .. _cli_wait:
  863. ``wait``
  864. --------
  865. ::
  866. Usage: docker wait [OPTIONS] NAME
  867. Block until a container stops, then print its exit code.