Browse code

Use "sudo" for dockerd examples

Because we standardize on using a non-privileged
prompt (`$`) instead of `#`, replacing the
examples to use `sudo` instead to indicate
this has to be run as root.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2016/09/17 00:22:58
Showing 1 changed files
... ...
@@ -123,26 +123,32 @@ find examples of using Systemd socket activation with Docker and Systemd in the
123 123
 You can configure the Docker daemon to listen to multiple sockets at the same
124 124
 time using multiple `-H` options:
125 125
 
126
-    # listen using the default unix socket, and on 2 specific IP addresses on this host.
127
-    dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
126
+```bash
127
+# listen using the default unix socket, and on 2 specific IP addresses on this host.
128
+$ sudo dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
129
+```
128 130
 
129 131
 The Docker client will honor the `DOCKER_HOST` environment variable to set the
130 132
 `-H` flag for the client.
131 133
 
132
-    $ docker -H tcp://0.0.0.0:2375 ps
133
-    # or
134
-    $ export DOCKER_HOST="tcp://0.0.0.0:2375"
135
-    $ docker ps
136
-    # both are equal
134
+```bash
135
+$ docker -H tcp://0.0.0.0:2375 ps
136
+# or
137
+$ export DOCKER_HOST="tcp://0.0.0.0:2375"
138
+$ docker ps
139
+# both are equal
140
+```
137 141
 
138 142
 Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than
139 143
 the empty string is equivalent to setting the `--tlsverify` flag. The following
140 144
 are equivalent:
141 145
 
142
-    $ docker --tlsverify ps
143
-    # or
144
-    $ export DOCKER_TLS_VERIFY=1
145
-    $ docker ps
146
+```bash
147
+$ docker --tlsverify ps
148
+# or
149
+$ export DOCKER_TLS_VERIFY=1
150
+$ docker ps
151
+```
146 152
 
147 153
 The Docker client will honor the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`
148 154
 environment variables (or the lowercase versions thereof). `HTTPS_PROXY` takes
... ...
@@ -188,27 +194,31 @@ For example:
188 188
 `-H`, when empty, will default to the same value as
189 189
 when no `-H` was passed in.
190 190
 
191
-`-H` also accepts short form for TCP bindings:
192
-
193
-    `host:` or `host:port` or `:port`
191
+`-H` also accepts short form for TCP bindings: `host:` or `host:port` or `:port`
194 192
 
195 193
 Run Docker in daemon mode:
196 194
 
197
-    $ sudo <path to>/dockerd -H 0.0.0.0:5555 &
195
+```bash
196
+$ sudo <path to>/dockerd -H 0.0.0.0:5555 &
197
+```
198 198
 
199 199
 Download an `ubuntu` image:
200 200
 
201
-    $ docker -H :5555 pull ubuntu
201
+```bash
202
+$ docker -H :5555 pull ubuntu
203
+```
202 204
 
203 205
 You can use multiple `-H`, for example, if you want to listen on both
204 206
 TCP and a Unix socket
205 207
 
206
-    # Run docker in daemon mode
207
-    $ sudo <path to>/dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock &
208
-    # Download an ubuntu image, use default Unix socket
209
-    $ docker pull ubuntu
210
-    # OR use the TCP port
211
-    $ docker -H tcp://127.0.0.1:2375 pull ubuntu
208
+```bash
209
+# Run docker in daemon mode
210
+$ sudo <path to>/dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock &
211
+# Download an ubuntu image, use default Unix socket
212
+$ docker pull ubuntu
213
+# OR use the TCP port
214
+$ docker -H tcp://127.0.0.1:2375 pull ubuntu
215
+```
212 216
 
213 217
 ### Daemon storage-driver option
214 218
 
... ...
@@ -272,29 +282,30 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
272 272
 
273 273
 *  `dm.thinpooldev`
274 274
 
275
-     Specifies a custom block storage device to use for the thin pool.
275
+    Specifies a custom block storage device to use for the thin pool.
276 276
 
277
-     If using a block device for device mapper storage, it is best to use `lvm`
278
-     to create and manage the thin-pool volume. This volume is then handed to Docker
279
-     to exclusively create snapshot volumes needed for images and containers.
277
+    If using a block device for device mapper storage, it is best to use `lvm`
278
+    to create and manage the thin-pool volume. This volume is then handed to Docker
279
+    to exclusively create snapshot volumes needed for images and containers.
280 280
 
281
-     Managing the thin-pool outside of Engine makes for the most feature-rich
282
-     method of having Docker utilize device mapper thin provisioning as the
283
-     backing storage for Docker containers. The highlights of the lvm-based
284
-     thin-pool management feature include: automatic or interactive thin-pool
285
-     resize support, dynamically changing thin-pool features, automatic thinp
286
-     metadata checking when lvm activates the thin-pool, etc.
281
+    Managing the thin-pool outside of Engine makes for the most feature-rich
282
+    method of having Docker utilize device mapper thin provisioning as the
283
+    backing storage for Docker containers. The highlights of the lvm-based
284
+    thin-pool management feature include: automatic or interactive thin-pool
285
+    resize support, dynamically changing thin-pool features, automatic thinp
286
+    metadata checking when lvm activates the thin-pool, etc.
287 287
 
288
-     As a fallback if no thin pool is provided, loopback files are
289
-     created. Loopback is very slow, but can be used without any
290
-     pre-configuration of storage. It is strongly recommended that you do
291
-     not use loopback in production. Ensure your Engine daemon has a
292
-     `--storage-opt dm.thinpooldev` argument provided.
288
+    As a fallback if no thin pool is provided, loopback files are
289
+    created. Loopback is very slow, but can be used without any
290
+    pre-configuration of storage. It is strongly recommended that you do
291
+    not use loopback in production. Ensure your Engine daemon has a
292
+    `--storage-opt dm.thinpooldev` argument provided.
293 293
 
294
-     Example use:
294
+    Example use:
295 295
 
296
-        $ dockerd \
297
-              --storage-opt dm.thinpooldev=/dev/mapper/thin-pool
296
+    ```bash
297
+    $ sudo dockerd --storage-opt dm.thinpooldev=/dev/mapper/thin-pool
298
+    ```
298 299
 
299 300
 *  `dm.basesize`
300 301
 
... ...
@@ -310,7 +321,10 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
310 310
 
311 311
     Example use:
312 312
 
313
-        $ dockerd --storage-opt dm.basesize=50G
313
+    ```bash
314
+    $ sudo dockerd --storage-opt dm.basesize=50G
315
+    ```
316
+
314 317
 
315 318
     This will increase the base device size to 50G. The Docker daemon will throw an
316 319
     error if existing base device size is larger than 50G. A user can use
... ...
@@ -320,19 +334,23 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
320 320
     that may already be initialized and inherited by pulled images. Typically,
321 321
     a change to this value requires additional steps to take effect:
322 322
 
323
-        $ sudo service docker stop
324
-        $ sudo rm -rf /var/lib/docker
325
-        $ sudo service docker start
323
+     ```bash
324
+    $ sudo service docker stop
325
+    $ sudo rm -rf /var/lib/docker
326
+    $ sudo service docker start
327
+    ```
326 328
 
327 329
     Example use:
328 330
 
329
-        $ dockerd --storage-opt dm.basesize=20G
331
+    ```bash
332
+    $ sudo dockerd --storage-opt dm.basesize=20G
333
+    ```
330 334
 
331 335
 *  `dm.loopdatasize`
332 336
 
333 337
     > **Note**:
334
-	> This option configures devicemapper loopback, which should not
335
-	> be used in production.
338
+    > This option configures devicemapper loopback, which should not
339
+    > be used in production.
336 340
 
337 341
     Specifies the size to use when creating the loopback file for the
338 342
     "data" device which is used for the thin pool. The default size is
... ...
@@ -341,7 +359,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
341 341
 
342 342
     Example use:
343 343
 
344
-        $ dockerd --storage-opt dm.loopdatasize=200G
344
+    ```bash
345
+    $ sudo dockerd --storage-opt dm.loopdatasize=200G
346
+    ```
345 347
 
346 348
 *  `dm.loopmetadatasize`
347 349
 
... ...
@@ -356,7 +376,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
356 356
 
357 357
     Example use:
358 358
 
359
-        $ dockerd --storage-opt dm.loopmetadatasize=4G
359
+    ```bash
360
+    $ sudo dockerd --storage-opt dm.loopmetadatasize=4G
361
+    ```
360 362
 
361 363
 *  `dm.fs`
362 364
 
... ...
@@ -365,7 +387,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
365 365
 
366 366
     Example use:
367 367
 
368
-        $ dockerd --storage-opt dm.fs=ext4
368
+    ```bash
369
+    $ sudo dockerd --storage-opt dm.fs=ext4
370
+    ```
369 371
 
370 372
 *  `dm.mkfsarg`
371 373
 
... ...
@@ -373,7 +397,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
373 373
 
374 374
     Example use:
375 375
 
376
-        $ dockerd --storage-opt "dm.mkfsarg=-O ^has_journal"
376
+    ```bash
377
+    $ sudo dockerd --storage-opt "dm.mkfsarg=-O ^has_journal"
378
+    ```
377 379
 
378 380
 *  `dm.mountopt`
379 381
 
... ...
@@ -381,7 +407,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
381 381
 
382 382
     Example use:
383 383
 
384
-        $ dockerd --storage-opt dm.mountopt=nodiscard
384
+    ```bash
385
+    $ sudo dockerd --storage-opt dm.mountopt=nodiscard
386
+    ```
385 387
 
386 388
 *  `dm.datadev`
387 389
 
... ...
@@ -395,9 +423,11 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
395 395
 
396 396
     Example use:
397 397
 
398
-        $ dockerd \
399
-              --storage-opt dm.datadev=/dev/sdb1 \
400
-              --storage-opt dm.metadatadev=/dev/sdc1
398
+    ```bash
399
+    $ sudo dockerd \
400
+          --storage-opt dm.datadev=/dev/sdb1 \
401
+          --storage-opt dm.metadatadev=/dev/sdc1
402
+    ```
401 403
 
402 404
 *  `dm.metadatadev`
403 405
 
... ...
@@ -411,13 +441,17 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
411 411
     If setting up a new metadata pool it is required to be valid. This can be
412 412
     achieved by zeroing the first 4k to indicate empty metadata, like this:
413 413
 
414
-        $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1
414
+    ```bash
415
+    $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1
416
+    ```
415 417
 
416 418
     Example use:
417 419
 
418
-        $ dockerd \
419
-              --storage-opt dm.datadev=/dev/sdb1 \
420
-              --storage-opt dm.metadatadev=/dev/sdc1
420
+    ```bash
421
+    $ sudo dockerd \
422
+          --storage-opt dm.datadev=/dev/sdb1 \
423
+          --storage-opt dm.metadatadev=/dev/sdc1
424
+    ```
421 425
 
422 426
 *  `dm.blocksize`
423 427
 
... ...
@@ -426,7 +460,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
426 426
 
427 427
     Example use:
428 428
 
429
-        $ dockerd --storage-opt dm.blocksize=512K
429
+    ```bash
430
+    $ sudo dockerd --storage-opt dm.blocksize=512K
431
+    ```
430 432
 
431 433
 *  `dm.blkdiscard`
432 434
 
... ...
@@ -440,7 +476,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
440 440
 
441 441
     Example use:
442 442
 
443
-        $ dockerd --storage-opt dm.blkdiscard=false
443
+    ```bash
444
+    $ sudo dockerd --storage-opt dm.blkdiscard=false
445
+    ```
444 446
 
445 447
 *  `dm.override_udev_sync_check`
446 448
 
... ...
@@ -450,10 +488,12 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
450 450
     To view the `udev` sync support of a Docker daemon that is using the
451 451
     `devicemapper` driver, run:
452 452
 
453
-        $ docker info
454
-        [...]
455
-        Udev Sync Supported: true
456
-        [...]
453
+    ```bash
454
+    $ docker info
455
+    [...]
456
+    Udev Sync Supported: true
457
+    [...]
458
+    ```
457 459
 
458 460
     When `udev` sync support is `true`, then `devicemapper` and udev can
459 461
     coordinate the activation and deactivation of devices for containers.
... ...
@@ -466,7 +506,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
466 466
     To allow the `docker` daemon to start, regardless of `udev` sync not being
467 467
     supported, set `dm.override_udev_sync_check` to true:
468 468
 
469
-        $ dockerd --storage-opt dm.override_udev_sync_check=true
469
+    ```bash
470
+    $ sudo dockerd --storage-opt dm.override_udev_sync_check=true
471
+    ```
470 472
 
471 473
     When this value is `true`, the  `devicemapper` continues and simply warns
472 474
     you the errors are happening.
... ...
@@ -496,7 +538,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
496 496
 
497 497
     Example use:
498 498
 
499
-        $ dockerd --storage-opt dm.use_deferred_removal=true
499
+    ```bash
500
+    $ sudo dockerd --storage-opt dm.use_deferred_removal=true
501
+    ```
500 502
 
501 503
 *  `dm.use_deferred_deletion`
502 504
 
... ...
@@ -510,9 +554,11 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
510 510
     To avoid this failure, enable both deferred device deletion and deferred
511 511
     device removal on the daemon.
512 512
 
513
-        $ dockerd \
514
-              --storage-opt dm.use_deferred_deletion=true \
515
-              --storage-opt dm.use_deferred_removal=true
513
+    ```bash
514
+    $ sudo dockerd \
515
+          --storage-opt dm.use_deferred_deletion=true \
516
+          --storage-opt dm.use_deferred_removal=true
517
+    ```
516 518
 
517 519
     With these two options enabled, if a device is busy when the driver is
518 520
     deleting a container, the driver marks the device as deleted. Later, when
... ...
@@ -549,7 +595,7 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
549 549
     Example use:
550 550
 
551 551
     ```bash
552
-    $ dockerd --storage-opt dm.min_free_space=10%
552
+    $ sudo dockerd --storage-opt dm.min_free_space=10%
553 553
     ```
554 554
 
555 555
 *  `dm.xfs_nospace_max_retries`
... ...
@@ -565,7 +611,7 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
565 565
     Example use:
566 566
 
567 567
     ```bash
568
-    $ dockerd --storage-opt dm.xfs_nospace_max_retries=0
568
+    $ sudo dockerd --storage-opt dm.xfs_nospace_max_retries=0
569 569
     ```
570 570
 
571 571
 #### ZFS options
... ...
@@ -578,7 +624,9 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
578 578
 
579 579
     Example use:
580 580
 
581
-        $ dockerd -s zfs --storage-opt zfs.fsname=zroot/docker
581
+    ```bash
582
+    $ sudo dockerd -s zfs --storage-opt zfs.fsname=zroot/docker
583
+    ```
582 584
 
583 585
 #### Btrfs options
584 586
 
... ...
@@ -590,7 +638,10 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
590 590
     **size** cannot be smaller than **btrfs.min_space**.
591 591
 
592 592
     Example use:
593
-        $ dockerd -s btrfs --storage-opt btrfs.min_space=10G
593
+
594
+    ```bash
595
+    $ sudo dockerd -s btrfs --storage-opt btrfs.min_space=10G
596
+    ```
594 597
 
595 598
 #### Overlay2 options
596 599
 
... ...
@@ -615,7 +666,7 @@ control `containerd` startup, manually start `containerd` and pass the path to
615 615
 the `containerd` socket using the `--containerd` flag. For example:
616 616
 
617 617
 ```bash
618
-$ dockerd --containerd /var/run/dev/docker-containerd.sock
618
+$ sudo dockerd --containerd /var/run/dev/docker-containerd.sock
619 619
 ```
620 620
 
621 621
 Runtimes can be registered with the daemon either via the
... ...
@@ -639,9 +690,11 @@ The following is an example adding 2 runtimes via the configuration:
639 639
 
640 640
 This is the same example via the command line:
641 641
 
642
-    $ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-runc-replacement
642
+```bash
643
+$ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-runc-replacement
644
+```
643 645
 
644
-**Note**: defining runtime arguments via the command line is not supported.
646
+> **Note**: defining runtime arguments via the command line is not supported.
645 647
 
646 648
 ## Options for the runtime
647 649
 
... ...
@@ -656,14 +709,18 @@ cgroups. You can specify only specify `cgroupfs` or `systemd`. If you specify
656 656
 
657 657
 This example sets the `cgroupdriver` to `systemd`:
658 658
 
659
-    $ sudo dockerd --exec-opt native.cgroupdriver=systemd
659
+```bash
660
+$ sudo dockerd --exec-opt native.cgroupdriver=systemd
661
+```
660 662
 
661 663
 Setting this option applies to all containers the daemon launches.
662 664
 
663 665
 Also Windows Container makes use of `--exec-opt` for special purpose. Docker user
664 666
 can specify default container isolation technology with this, for example:
665 667
 
666
-    $ dockerd --exec-opt isolation=hyperv
668
+```bash
669
+$ sudo dockerd --exec-opt isolation=hyperv
670
+```
667 671
 
668 672
 Will make `hyperv` the default isolation technology on Windows. If no isolation
669 673
 value is specified on daemon start, on Windows client, the default is
... ...
@@ -671,11 +728,19 @@ value is specified on daemon start, on Windows client, the default is
671 671
 
672 672
 ## Daemon DNS options
673 673
 
674
-To set the DNS server for all Docker containers, use
675
-`dockerd --dns 8.8.8.8`.
674
+To set the DNS server for all Docker containers, use:
675
+
676
+```bash
677
+$ sudo dockerd --dns 8.8.8.8
678
+```
679
+
680
+
681
+To set the DNS search domain for all Docker containers, use:
682
+
683
+```bash
684
+$ sudo dockerd --dns-search example.com
685
+```
676 686
 
677
-To set the DNS search domain for all Docker containers, use
678
-`dockerd --dns-search example.com`.
679 687
 
680 688
 ## Insecure registries
681 689
 
... ...
@@ -770,7 +835,7 @@ using the `--cluster-store-opt` flag, specifying the paths to PEM encoded
770 770
 files. For example:
771 771
 
772 772
 ```bash
773
-dockerd \
773
+$ sudo dockerd \
774 774
     --cluster-advertise 192.168.1.2:2376 \
775 775
     --cluster-store etcd://192.168.1.2:2379 \
776 776
     --cluster-store-opt kv.cacertfile=/path/to/ca.pem \
... ...
@@ -820,7 +885,7 @@ authorization plugins when you start the Docker `daemon` using the
820 820
 `--authorization-plugin=PLUGIN_ID` option.
821 821
 
822 822
 ```bash
823
-dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,...
823
+$ sudo dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,...
824 824
 ```
825 825
 
826 826
 The `PLUGIN_ID` value is either the plugin's name or a path to its specification
... ...
@@ -891,10 +956,10 @@ startup will fail with an error message.
891 891
 > *before* the `--userns-remap` option is enabled. Once these files exist, the
892 892
 > daemon can be (re)started and range assignment on user creation works properly.
893 893
 
894
-*Example: starting with default Docker user management:*
894
+**Example: starting with default Docker user management:**
895 895
 
896 896
 ```bash
897
-$ dockerd --userns-remap=default
897
+$ sudo dockerd --userns-remap=default
898 898
 ```
899 899
 
900 900
 When `default` is provided, Docker will create - or find the existing - user and group
... ...
@@ -1237,7 +1302,7 @@ The `--tls*` options enable use of specific certificates for individual daemons.
1237 1237
 Example script for a separate “bootstrap” instance of the Docker daemon without network:
1238 1238
 
1239 1239
 ```bash
1240
-$ dockerd \
1240
+$ sudo dockerd \
1241 1241
         -H unix:///var/run/docker-bootstrap.sock \
1242 1242
         -p /var/run/docker-bootstrap.pid \
1243 1243
         --iptables=false \