You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51-48Lines changed: 51 additions & 48 deletions
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ The 3.10.x kernel is [the minimum requirement](https://docs.docker.com/engine/in
39
39
40
40
### MacOS
41
41
42
-
10.8 “Mountain Lion” or newer is required.
42
+
10.8 “Mountain Lion” or newer is required.
43
43
44
44
## Installation
45
45
@@ -56,9 +56,10 @@ If you're not willing to run a random shell script, please see the [installation
56
56
If you are a complete Docker newbie, you should follow the [series of tutorials](https://docs.docker.com/engine/getstarted/) now.
57
57
58
58
### macOS
59
+
59
60
Download and install [Docker Community Edition](https://www.docker.com/community-edition). if you have Homebrew-Cask, just type `brew cask install docker`. Or Download and install [Docker Toolbox](https://docs.docker.com/toolbox/overview/). [Docker For Mac](https://docs.docker.com/docker-for-mac/) is nice, but it's not quite as finished as the VirtualBox install. [See the comparison](https://docs.docker.com/docker-for-mac/docker-toolbox/).
60
61
61
-
> **NOTE** Docker Toolbox is legacy. you should to use Docker Community Edition, See (Docker Toolbox)[https://docs.docker.com/toolbox/overview/]
62
+
> **NOTE** Docker Toolbox is legacy. You should to use Docker Community Edition, See [Docker Toolbox](https://docs.docker.com/toolbox/overview/).
62
63
63
64
Once you've installed Docker Community Edition, click the docker icon in Launchpad. Then start up a container:
64
65
@@ -70,6 +71,28 @@ That's it, you have a running Docker container.
70
71
71
72
If you are a complete Docker newbie, you should probably follow the [series of tutorials](https://docs.docker.com/engine/getstarted/) now.
72
73
74
+
### Check Version
75
+
76
+
It is very important that you always know the current version of Docker you are currently running on at any point in time. This is very helpful because you get to know what features are compatible with what you have running. This is also important because you know what containers to run from the docker store when you are trying to get template containers. That said let see how to know which version of docker we have running currently.
77
+
78
+
*[`docker version`](https://docs.docker.com/engine/reference/commandline/version/) shows which version of docker you have running.
[Your basic isolated Docker process](http://etherealmind.com/basics-docker-containers-hypervisors-coreos/). Containers are to Virtual Machines as threads are to processes. Or you can think of them as chroots on steroids.
@@ -116,19 +139,19 @@ Restart policies on crashed docker instances are [covered here](http://container
116
139
117
140
You can limit CPU, either using a percentage of all CPUs, or by using specific cores.
118
141
119
-
For example, you can tell the [`cpu-shares`](https://docs.docker.com/engine/reference/run/#/cpu-share-constraint) setting. The setting is a bit strange -- 1024 means 100% of the CPU, so if you want the container to take 50% of all CPU cores, you should specify 512. See https://goldmann.pl/blog/2014/09/11/resource-management-in-docker/#_cpu for more:
142
+
For example, you can tell the [`cpu-shares`](https://docs.docker.com/engine/reference/run/#/cpu-share-constraint) setting. The setting is a bit strange -- 1024 means 100% of the CPU, so if you want the container to take 50% of all CPU cores, you should specify 512. See <https://goldmann.pl/blog/2014/09/11/resource-management-in-docker/#_cpu> for more:
120
143
121
144
```
122
145
docker run -ti -c 512 agileek/cpuset-test
123
146
```
124
147
125
-
You can also only use some CPU cores using [`cpuset-cpus`](https://docs.docker.com/engine/reference/run/#/cpuset-constraint). See https://agileek.github.io/docker/2014/08/06/docker-cpuset/ for details and some nice videos:
148
+
You can also only use some CPU cores using [`cpuset-cpus`](https://docs.docker.com/engine/reference/run/#/cpuset-constraint). See <https://agileek.github.io/docker/2014/08/06/docker-cpuset/> for details and some nice videos:
126
149
127
150
```
128
151
docker run -ti --cpuset-cpus=0,4,6 agileek/cpuset-test
129
152
```
130
153
131
-
Note that Docker can still **see** all of the CPUs inside the container -- it just isn't using all of them. See https://github.com/docker/docker/issues/20770 for more details.
154
+
Note that Docker can still **see** all of the CPUs inside the container -- it just isn't using all of them. See <https://github.com/docker/docker/issues/20770> for more details.
Linux capabilities can be set by using `cap-add` and `cap-drop`. See https://docs.docker.com/engine/reference/run/#/runtime-privilege-and-linux-capabilities for details. This should be used for greater security.
166
+
Linux capabilities can be set by using `cap-add` and `cap-drop`. See <https://docs.docker.com/engine/reference/run/#/runtime-privilege-and-linux-capabilities> for details. This should be used for greater security.
144
167
145
168
To mount a FUSE based filesystem, you need to combine both --cap-add and --device:
146
169
@@ -160,9 +183,8 @@ Give access to all devices:
160
183
docker run -it --privileged -v /dev/bus/usb:/dev/bus/usb debian bash
`docker ps -a` shows running and stopped containers.
179
201
180
-
`docker stats --all` shows a running list of containers.
202
+
`docker stats --all` shows a list of all containers, default shows just running.
181
203
182
204
### Import / Export
183
205
@@ -209,25 +231,9 @@ Images are just [templates for docker containers](https://docs.docker.com/engine
209
231
*[`docker history`](https://docs.docker.com/engine/reference/commandline/history) shows history of image.
210
232
*[`docker tag`](https://docs.docker.com/engine/reference/commandline/tag) tags an image to a name (local or registry).
211
233
212
-
## Checking Docker Version
213
-
214
-
It is very important that you always know the current version of Docker you are currently running on at any point in time.This is very helpful because you get to know what features are compatible with what you have running. This is also important because you know what containers to run from the docker store when you are trying to get template containers. That said let see how to know what version of docker we have running currently
215
-
216
-
*['docker version'](https://docs.docker.com/engine/reference/commandline/version/) check what version of docker you have running
While you can use the `docker rmi` command to remove specific images, there's a tool called [docker-gc](https://github.com/spotify/docker-gc) that will safely clean up images that are no longer used by any containers.
236
+
While you can use the `docker rmi` command to remove specific images, there's a tool called [docker-gc](https://github.com/spotify/docker-gc) that will safely clean up images that are no longer used by any containers. As of docker 1.13, `docker image prune` is also available for removing unused images. See [Prune](#prune).
231
237
232
238
### Load/Save image
233
239
@@ -334,15 +340,15 @@ Here are some common text editors and their syntax highlighting modules you coul
334
340
*[EXPOSE](https://docs.docker.com/engine/reference/builder/#expose) informs Docker that the container listens on the specified network ports at runtime. NOTE: does not actually make ports accessible.
*[ADD](https://docs.docker.com/engine/reference/builder/#add) copies new files, directories or remote file to container. Invalidates caches. Avoid `ADD` and use `COPY` instead.
337
-
*[COPY](https://docs.docker.com/engine/reference/builder/#copy) copies new files or directories to container. Note that this only copies as root, so you have to chown manually regardless of your USER / WORKDIR setting. See https://github.com/moby/moby/issues/30110
343
+
*[COPY](https://docs.docker.com/engine/reference/builder/#copy) copies new files or directories to container. Note that this only copies as root, so you have to chown manually regardless of your USER / WORKDIR setting, as same as `ADD`. See <https://github.com/moby/moby/issues/30110>
338
344
*[ENTRYPOINT](https://docs.docker.com/engine/reference/builder/#entrypoint) configures a container that will run as an executable.
339
345
*[VOLUME](https://docs.docker.com/engine/reference/builder/#volume) creates a mount point for externally mounted volumes or other containers.
340
346
*[USER](https://docs.docker.com/engine/reference/builder/#user) sets the user name for following RUN / CMD / ENTRYPOINT commands.
341
347
*[WORKDIR](https://docs.docker.com/engine/reference/builder/#workdir) sets the working directory.
342
348
*[ARG](https://docs.docker.com/engine/reference/builder/#arg) defines a build-time variable.
343
349
*[ONBUILD](https://docs.docker.com/engine/reference/builder/#onbuild) adds a trigger instruction when the image is used as the base for another build.
344
350
*[STOPSIGNAL](https://docs.docker.com/engine/reference/builder/#stopsignal) sets the system call signal that will be sent to the container to exit.
345
-
*[LABEL](https://docs.docker.com/engine/userguide/labels-custom-metadata/) apply key/value metadata to your images, containers, or daemons.
351
+
*[LABEL](https://docs.docker.com/config/labels-custom-metadata/) apply key/value metadata to your images, containers, or daemons.
346
352
347
353
### Tutorial
348
354
@@ -363,9 +369,9 @@ The versioned filesystem in Docker is based on layers. They're like [git commits
363
369
364
370
## Links
365
371
366
-
Links are how Docker containers talk to each other [through TCP/IP ports](https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/). [Linking into Redis](https://docs.docker.com/engine/examples/running_redis_service/) and [Atlassian](https://blogs.atlassian.com/2013/11/docker-all-the-things-at-atlassian-automation-and-wiring/) show worked examples. You can also resolve [links by hostname](https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/#/updating-the-etchosts-file).
372
+
Links are how Docker containers talk to each other [through TCP/IP ports](https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/). [Atlassian](https://blogs.atlassian.com/2013/11/docker-all-the-things-at-atlassian-automation-and-wiring/) show worked examples. You can also resolve [links by hostname](https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/#/updating-the-etchosts-file).
367
373
368
-
This has been deprected to some extent by [user-defined networks](https://docs.docker.com/engine/userguide/networking/#user-defined-networks).
374
+
This has been deprecated to some extent by [user-defined networks](https://docs.docker.com/network/).
369
375
370
376
NOTE: If you want containers to ONLY communicate with each other through links, start the docker daemon with `-icc=false` to disable inter process communication.
371
377
@@ -396,7 +402,7 @@ Generally, linking between docker services is a subset of "service discovery", a
396
402
397
403
## Volumes
398
404
399
-
Docker volumes are [free-floating filesystems](https://docs.docker.com/engine/tutorials/dockervolumes/). They don't have to be connected to a particular container. You should use volumes mounted from [data-only containers](https://medium.com/@ramangupta/why-docker-data-containers-are-good-589b3c6c749e) for portability.
405
+
Docker volumes are [free-floating filesystems](https://docs.docker.com/engine/tutorials/dockervolumes/). They don't have to be connected to a particular container. You can use volumes mounted from [data-only containers](https://medium.com/@ramangupta/why-docker-data-containers-are-good-589b3c6c749e) for portability. As of Docker 1.9.0, Docker has named volumes which replace data-only containers. Consider using named volumes to implement it rather than data containers.
400
406
401
407
### Lifecycle
402
408
@@ -414,7 +420,7 @@ You can mount them in several docker containers at once, using `docker run --vol
414
420
415
421
Because volumes are isolated filesystems, they are often used to store state from computations between transient containers. That is, you can have a stateless and transient container run from a recipe, blow it away, and then have a second instance of the transient container pick up from where the last one left off.
416
422
417
-
See [advanced volumes](http://crosbymichael.com/advanced-docker-volumes.html) for more details. Container42 is [also helpful](http://container42.com/2014/11/03/docker-indepth-volumes/).
423
+
See [advanced volumes](http://crosbymichael.com/advanced-docker-volumes.html) for more details. [Container42](http://container42.com/2014/11/03/docker-indepth-volumes/) is also helpful.
418
424
419
425
You can [map MacOS host directories as docker volumes](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-a-data-volume):
420
426
@@ -426,7 +432,7 @@ You can use remote NFS volumes if you're [feeling brave](https://docs.docker.com
426
432
427
433
You may also consider running data-only containers as described [here](http://container42.com/2013/12/16/persistent-volumes-with-docker-container-as-volume-pattern/) to provide some data portability.
428
434
429
-
[Be aware that you can mount files as volumes.](#volumes-can-be-files)
435
+
Be aware that you can [mount files as volumes](#volumes-can-be-files).
430
436
431
437
## Exposing ports
432
438
@@ -484,7 +490,7 @@ This is where general Docker best practices and war stories go:
484
490
485
491
This is where security tips about Docker go. The Docker [security](https://docs.docker.com/engine/security/security/) page goes into more detail.
486
492
487
-
First things first: Docker runs as root. If you are in the `docker` group, you effectively [have root access](http://reventlov.com/advisories/using-the-docker-command-to-root-the-host). If you expose the docker unix socket to a container, you are giving the container [root access to the host](https://www.lvh.io/posts/dont-expose-the-docker-socket-not-even-to-a-container.html).
493
+
First things first: Docker runs as root. If you are in the `docker` group, you effectively [have root access](https://web.archive.org/web/20161226211755/http://reventlov.com/advisories/using-the-docker-command-to-root-the-host). If you expose the docker unix socket to a container, you are giving the container [root access to the host](https://www.lvh.io/posts/dont-expose-the-docker-socket-not-even-to-a-container.html).
488
494
489
495
Docker should not be your only defense. You should secure and harden it.
490
496
@@ -498,7 +504,7 @@ Docker image ids are [sensitive information](https://medium.com/@quayio/your-doc
498
504
499
505
See the [Docker Security Cheat Sheet](https://github.com/konstruktoid/Docker/blob/master/Security/CheatSheet.adoc) by [Thomas Sjögren](https://github.com/konstruktoid): some good stuff about container hardening in there.
500
506
501
-
Check out the [docker bench security script](https://github.com/docker/docker-bench-security), download the [white papers](https://blog.docker.com/2015/05/understanding-docker-security-and-best-practices/) and subscribe to the [mailing lists](https://www.docker.com/docker-security) (unfortunately Docker does not have a unique mailing list, only dev / user).
507
+
Check out the [docker bench security script](https://github.com/docker/docker-bench-security), download the [white papers](https://blog.docker.com/2015/05/understanding-docker-security-and-best-practices/).
502
508
503
509
You should start off by using a kernel with unstable patches for grsecurity / pax compiled in, such as [Alpine Linux](https://en.wikipedia.org/wiki/Alpine_Linux). If you are using grsecurity in production, you should spring for [commercial support](https://grsecurity.net/business_support.php) for the [stable patches](https://grsecurity.net/announce.php), same as you would do for RedHat. It's $200 a month, which is nothing to your devops budget.
504
510
@@ -582,7 +588,7 @@ The new [Data Management Commands](https://github.com/docker/docker/pull/26108)
582
588
*`docker container prune`
583
589
*`docker image prune`
584
590
585
-
### df
591
+
### df
586
592
587
593
`docker system df` presents a summary of the space currently used by different docker objects.
0 commit comments