diff --git a/storage/bind-mounts.md b/storage/bind-mounts.md index ca62e9fced..70968dd87c 100644 --- a/storage/bind-mounts.md +++ b/storage/bind-mounts.md @@ -103,7 +103,7 @@ first one.
-```bash +```console $ docker run -d \ -it \ --name devtest \ @@ -114,7 +114,7 @@ $ docker run -d \
-```bash +```console $ docker run -d \ -it \ --name devtest \ @@ -147,7 +147,7 @@ set to `rprivate`. Stop the container: -```bash +```console $ docker container stop devtest $ docker container rm devtest @@ -174,7 +174,7 @@ The `--mount` and `-v` examples have the same end result.
-```bash +```console $ docker run -d \ -it \ --name broken-container \ @@ -188,7 +188,7 @@ starting container process caused "exec: \"nginx\": executable file not found in
-```bash +```console $ docker run -d \ -it \ --name broken-container \ @@ -204,7 +204,7 @@ starting container process caused "exec: \"nginx\": executable file not found in The container is created but does not start. Remove it: -```bash +```console $ docker container rm broken-container ``` @@ -228,7 +228,7 @@ The `--mount` and `-v` examples have the same result.
-```bash +```console $ docker run -d \ -it \ --name devtest \ @@ -239,7 +239,7 @@ $ docker run -d \
-```bash +```console $ docker run -d \ -it \ --name devtest \ @@ -268,7 +268,7 @@ correctly. Look for the `Mounts` section: Stop the container: -```bash +```console $ docker container stop devtest $ docker container rm devtest @@ -316,7 +316,7 @@ The `--mount` and `-v` examples have the same result.
-```bash +```console $ docker run -d \ -it \ --name devtest \ @@ -328,7 +328,7 @@ $ docker run -d \
-```bash +```console $ docker run -d \ -it \ --name devtest \ @@ -367,7 +367,7 @@ the bind mount's contents: It is not possible to modify the selinux label using the `--mount` flag. -```bash +```console $ docker run -d \ -it \ --name devtest \ diff --git a/storage/storagedriver/aufs-driver.md b/storage/storagedriver/aufs-driver.md index f7d681fff4..c49c575cf9 100644 --- a/storage/storagedriver/aufs-driver.md +++ b/storage/storagedriver/aufs-driver.md @@ -37,7 +37,7 @@ storage driver is configured, Docker uses it by default. 1. Use the following command to verify that your kernel supports AUFS. - ```bash + ```console $ grep aufs /proc/filesystems nodev aufs @@ -45,7 +45,7 @@ storage driver is configured, Docker uses it by default. 2. Check which storage driver Docker is using. - ```bash + ```console $ docker info @@ -88,7 +88,7 @@ minimize overhead. The following `docker pull` command shows a Docker host downloading a Docker image comprising five layers. -```bash +```console $ docker pull ubuntu Using default tag: latest diff --git a/storage/storagedriver/btrfs-driver.md b/storage/storagedriver/btrfs-driver.md index 3ddec45559..397c3706e2 100644 --- a/storage/storagedriver/btrfs-driver.md +++ b/storage/storagedriver/btrfs-driver.md @@ -41,7 +41,7 @@ Btrfs Filesystem as Btrfs. - `btrfs` support must exist in your kernel. To check this, run the following command: - ```bash + ```console $ grep btrfs /proc/filesystems btrfs @@ -60,7 +60,7 @@ This procedure is essentially identical on SLES and Ubuntu. 2. Copy the contents of `/var/lib/docker/` to a backup location, then empty the contents of `/var/lib/docker/`: - ```bash + ```console $ sudo cp -au /var/lib/docker /var/lib/docker.bk $ sudo rm -rf /var/lib/docker/* ``` @@ -70,7 +70,7 @@ This procedure is essentially identical on SLES and Ubuntu. `/dev/xvdg`. Double-check the block device names because this is a destructive operation. - ```bash + ```console $ sudo mkfs.btrfs -f /dev/xvdf /dev/xvdg ``` @@ -80,7 +80,7 @@ This procedure is essentially identical on SLES and Ubuntu. 4. Mount the new Btrfs filesystem on the `/var/lib/docker/` mount point. You can specify any of the block devices used to create the Btrfs filesystem. - ```bash + ```console $ sudo mount -t btrfs /dev/xvdf /var/lib/docker ``` @@ -89,7 +89,7 @@ This procedure is essentially identical on SLES and Ubuntu. 5. Copy the contents of `/var/lib/docker.bk` to `/var/lib/docker/`. - ```bash + ```console $ sudo cp -au /var/lib/docker.bk/* /var/lib/docker/ ``` @@ -112,7 +112,7 @@ This procedure is essentially identical on SLES and Ubuntu. 7. Start Docker. After it is running, verify that `btrfs` is being used as the storage driver. - ```bash + ```console $ docker info Containers: 0 @@ -140,7 +140,7 @@ roughly 1 GB. To add a block device to a Btrfs volume, use the `btrfs device add` and `btrfs filesystem balance` commands. -```bash +```console $ sudo btrfs device add /dev/svdh /var/lib/docker $ sudo btrfs filesystem balance /var/lib/docker diff --git a/storage/storagedriver/device-mapper-driver.md b/storage/storagedriver/device-mapper-driver.md index b429b50700..790492b644 100644 --- a/storage/storagedriver/device-mapper-driver.md +++ b/storage/storagedriver/device-mapper-driver.md @@ -57,7 +57,7 @@ For production systems, see 1. Stop Docker. - ```bash + ```console $ sudo systemctl stop docker ``` @@ -77,14 +77,14 @@ For production systems, see 3. Start Docker. - ```bash + ```console $ sudo systemctl start docker ``` 4. Verify that the daemon is using the `devicemapper` storage driver. Use the `docker info` command and look for `Storage Driver`. - ```bash + ```console $ docker info Containers: 0 @@ -204,7 +204,7 @@ assumes that the Docker daemon is in the `stopped` state. 2. Stop Docker. - ```bash + ```console $ sudo systemctl stop docker ``` @@ -222,7 +222,7 @@ assumes that the Docker daemon is in the `stopped` state. > **Warning**: The next few steps are destructive, so be sure that you have > specified the correct device! - ```bash + ```console $ sudo pvcreate /dev/xvdf Physical volume "/dev/xvdf" successfully created. @@ -231,7 +231,7 @@ assumes that the Docker daemon is in the `stopped` state. 5. Create a `docker` volume group on the same device, using the `vgcreate` command. - ```bash + ```console $ sudo vgcreate docker /dev/xvdf Volume group "docker" successfully created @@ -242,7 +242,7 @@ assumes that the Docker daemon is in the `stopped` state. to allow for automatic expanding of the data or metadata if space runs low, as a temporary stop-gap. These are the recommended values. - ```bash + ```console $ sudo lvcreate --wipesignatures y -n thinpool docker -l 95%VG Logical volume "thinpool" created. @@ -255,7 +255,7 @@ assumes that the Docker daemon is in the `stopped` state. 7. Convert the volumes to a thin pool and a storage location for metadata for the thin pool, using the `lvconvert` command. - ```bash + ```console $ sudo lvconvert -y \ --zero n \ -c 512K \ @@ -270,7 +270,7 @@ assumes that the Docker daemon is in the `stopped` state. 8. Configure autoextension of thin pools via an `lvm` profile. - ```bash + ```console $ sudo vi /etc/lvm/profile/docker-thinpool.profile ``` @@ -297,7 +297,7 @@ assumes that the Docker daemon is in the `stopped` state. 10. Apply the LVM profile, using the `lvchange` command. - ```bash + ```console $ sudo lvchange --metadataprofile docker-thinpool docker/thinpool Logical volume docker/thinpool changed. @@ -305,7 +305,7 @@ assumes that the Docker daemon is in the `stopped` state. 11. Ensure monitoring of the logical volume is enabled. - ```bash + ```console $ sudo lvs -o+seg_monitor LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Monitor @@ -317,7 +317,7 @@ assumes that the Docker daemon is in the `stopped` state. this step, automatic extension of the logical volume will not occur, regardless of any settings in the applied profile. - ```bash + ```console $ sudo lvchange --monitor y docker/thinpool ``` @@ -329,7 +329,7 @@ assumes that the Docker daemon is in the `stopped` state. exists, move it out of the way so that Docker can use the new LVM pool to store the contents of image and containers. - ```bash + ```console $ sudo su - # mkdir /var/lib/docker.bk # mv /var/lib/docker/* /var/lib/docker.bk @@ -358,19 +358,19 @@ assumes that the Docker daemon is in the `stopped` state. **systemd**: - ```bash + ```console $ sudo systemctl start docker ``` **service**: - ```bash + ```console $ sudo service docker start ``` 15. Verify that Docker is using the new configuration using `docker info`. - ```bash + ```console $ docker info Containers: 0 @@ -407,7 +407,7 @@ assumes that the Docker daemon is in the `stopped` state. 16. After you have verified that the configuration is correct, you can remove the `/var/lib/docker.bk` directory which contains the previous configuration. - ```bash + ```console $ sudo rm -rf /var/lib/docker.bk ``` @@ -422,7 +422,7 @@ tool at the OS level, such as Nagios. To view the LVM logs, you can use `journalctl`: -```bash +```console $ sudo journalctl -fu dm-event.service ``` @@ -464,7 +464,7 @@ If you do not want to use `device_tool`, you can [resize the thin pool manually] 2. Use the tool. The following example resizes the thin pool to 200GB. - ```bash + ```console $ ./device_tool resize 200GB ``` @@ -480,7 +480,7 @@ it has significant performance and stability drawbacks. If you are using `loop-lvm` mode, the output of `docker info` shows file paths for `Data loop file` and `Metadata loop file`: -```bash +```console $ docker info |grep 'loop file' Data loop file: /var/lib/docker/devicemapper/data @@ -492,7 +492,7 @@ thin pool is 100 GB, and is increased to 200 GB. 1. List the sizes of the devices. - ```bash + ```console $ sudo ls -lh /var/lib/docker/devicemapper/ total 1175492 @@ -504,13 +504,13 @@ thin pool is 100 GB, and is increased to 200 GB. which is used to increase **or** decrease the size of a file. Note that decreasing the size is a destructive operation. - ```bash + ```console $ sudo truncate -s 200G /var/lib/docker/devicemapper/data ``` 3. Verify the file size changed. - ```bash + ```console $ sudo ls -lh /var/lib/docker/devicemapper/ total 1.2G @@ -522,7 +522,7 @@ thin pool is 100 GB, and is increased to 200 GB. the loopback device in memory, in GB. Reload it, then list the size again. After the reload, the size is 200 GB. - ```bash + ```console $ echo $[ $(sudo blockdev --getsize64 /dev/loop0) / 1024 / 1024 / 1024 ] 100 @@ -578,7 +578,7 @@ block device and other parameters to suit your situation. Use the `pvdisplay` command to find the physical block devices currently in use by your thin pool, and the volume group's name. - ```bash + ```console $ sudo pvdisplay |grep 'VG Name' PV Name /dev/xvdf @@ -591,7 +591,7 @@ block device and other parameters to suit your situation. 2. Extend the volume group, using the `vgextend` command with the `VG Name` from the previous step, and the name of your **new** block device. - ```bash + ```console $ sudo vgextend docker /dev/xvdg Physical volume "/dev/xvdg" successfully created. @@ -602,7 +602,7 @@ block device and other parameters to suit your situation. volume right away, without auto-extend. To extend the metadata thinpool instead, use `docker/thinpool_tmeta`. - ```bash + ```console $ sudo lvextend -l+100%FREE -n docker/thinpool Size of logical volume docker/thinpool_tdata changed from 95.00 GiB (24319 extents) to 198.00 GiB (50688 extents). @@ -636,8 +636,8 @@ If you reboot the host and find that the `docker` service failed to start, look for the error, "Non existing device". You need to re-activate the logical volumes with this command: -```bash -sudo lvchange -ay docker/thinpool +```console +$ sudo lvchange -ay docker/thinpool ``` ## How the `devicemapper` storage driver works @@ -648,7 +648,7 @@ sudo lvchange -ay docker/thinpool Use the `lsblk` command to see the devices and their pools, from the operating system's point of view: -```bash +```console $ sudo lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT @@ -663,7 +663,7 @@ xvdf 202:80 0 100G 0 disk Use the `mount` command to see the mount-point Docker is using: -```bash +```console $ mount |grep devicemapper /dev/xvda1 on /var/lib/docker/devicemapper type xfs (rw,relatime,seclabel,attr2,inode64,noquota) ``` diff --git a/storage/storagedriver/overlayfs-driver.md b/storage/storagedriver/overlayfs-driver.md index f323d90c64..8c31ae5cd7 100644 --- a/storage/storagedriver/overlayfs-driver.md +++ b/storage/storagedriver/overlayfs-driver.md @@ -70,13 +70,13 @@ need to use the legacy `overlay` driver, specify it instead. 1. Stop Docker. - ```bash + ```console $ sudo systemctl stop docker ``` 2. Copy the contents of `/var/lib/docker` to a temporary location. - ```bash + ```console $ cp -au /var/lib/docker /var/lib/docker.bk ``` @@ -97,7 +97,7 @@ need to use the legacy `overlay` driver, specify it instead. 5. Start Docker. - ```bash + ```console $ sudo systemctl start docker ``` @@ -105,7 +105,7 @@ need to use the legacy `overlay` driver, specify it instead. Use the `docker info` command and look for `Storage Driver` and `Backing filesystem`. - ```bash + ```console $ docker info Containers: 0 @@ -149,7 +149,7 @@ six directories under `/var/lib/docker/overlay2`. > **Warning**: Do not directly manipulate any files or directories within > `/var/lib/docker/`. These files and directories are managed by Docker. -```bash +```console $ ls -l /var/lib/docker/overlay2 total 24 @@ -165,7 +165,7 @@ The new `l` (lowercase `L`) directory contains shortened layer identifiers as symbolic links. These identifiers are used to avoid hitting the page size limitation on arguments to the `mount` command. -```bash +```console $ ls -l /var/lib/docker/overlay2/l total 20 @@ -180,7 +180,7 @@ The lowest layer contains a file called `link`, which contains the name of the shortened identifier, and a directory called `diff` which contains the layer's contents. -```bash +```console $ ls /var/lib/docker/overlay2/3a36935c9df35472229c57f4a27105a136f5e4dbef0f87905b2e506e494e348b/ diff link @@ -200,7 +200,7 @@ contents. It also contains a `merged` directory, which contains the unified contents of its parent layer and itself, and a `work` directory which is used internally by OverlayFS. -```bash +```console $ ls /var/lib/docker/overlay2/223c2864175491657d238e2664251df13b63adb8d050924fd1bfcdb278b866f7 diff link lower merged work @@ -217,7 +217,7 @@ etc sbin usr var To view the mounts which exist when you use the `overlay` storage driver with Docker, use the `mount` command. The output below is truncated for readability. -```bash +```console $ mount | grep overlay overlay on /var/lib/docker/overlay2/9186877cdf386d0a3b016149cf30c208f326dca307529e646afce5b3f83f5304/merged @@ -273,7 +273,7 @@ the container is the `upperdir` and is writable. The following `docker pull` command shows a Docker host downloading a Docker image comprising five layers. -```bash +```console $ docker pull ubuntu Using default tag: latest @@ -297,7 +297,7 @@ the directory IDs. > **Warning**: Do not directly manipulate any files or directories within > `/var/lib/docker/`. These files and directories are managed by Docker. -```bash +```console $ ls -l /var/lib/docker/overlay/ total 20 @@ -312,7 +312,7 @@ The image layer directories contain the files unique to that layer as well as hard links to the data that is shared with lower layers. This allows for efficient use of disk space. -```bash +```console $ ls -i /var/lib/docker/overlay/38f3ed2eac129654acef11c32670b534670c3a06e483fce313d72e3e0a15baa8/root/bin/ls 19793696 /var/lib/docker/overlay/38f3ed2eac129654acef11c32670b534670c3a06e483fce313d72e3e0a15baa8/root/bin/ls @@ -328,7 +328,7 @@ Containers also exist on-disk in the Docker host's filesystem under `/var/lib/docker/overlay/`. If you list a running container's subdirectory using the `ls -l` command, three directories and one file exist: -```bash +```console $ ls -l /var/lib/docker/overlay/ total 16 @@ -341,7 +341,7 @@ drwx------ 3 root root 4096 Jun 20 16:39 work The `lower-id` file contains the ID of the top layer of the image the container is based on, which is the OverlayFS `lowerdir`. -```bash +```console $ cat /var/lib/docker/overlay/ec444863a55a9f1ca2df72223d459c5d940a721b2288ff86a3f27be28b53be6c/lower-id 55f1e14c361b90570df46371b20ce6d480c434981cbda5fd68c6ff61aa0a5358 @@ -358,7 +358,7 @@ The `work` directory is internal to OverlayFS. To view the mounts which exist when you use the `overlay` storage driver with Docker, use the `mount` command. The output below is truncated for readability. -```bash +```console $ mount | grep overlay overlay on /var/lib/docker/overlay/ec444863a55a.../merged diff --git a/storage/storagedriver/vfs-driver.md b/storage/storagedriver/vfs-driver.md index 470c3137b3..9b3f5160fb 100644 --- a/storage/storagedriver/vfs-driver.md +++ b/storage/storagedriver/vfs-driver.md @@ -17,7 +17,7 @@ mechanism to verify other storage back-ends against, in a testing environment. 1. Stop Docker. - ```bash + ```console $ sudo systemctl stop docker ``` @@ -44,14 +44,14 @@ mechanism to verify other storage back-ends against, in a testing environment. 3. Start Docker. - ```bash + ```console $ sudo systemctl start docker ``` 4. Verify that the daemon is using the `vfs` storage driver. Use the `docker info` command and look for `Storage Driver`. - ```bash + ```console $ docker info Storage Driver: vfs @@ -79,7 +79,7 @@ it is a deep copy of its parent layer. These layers are all located under The following `docker pull` command shows a Docker host downloading a Docker image comprising five layers. -```bash +```console $ docker pull ubuntu Using default tag: latest @@ -99,7 +99,7 @@ image layer IDs shown in the `docker pull` command. To see the size taken up on disk by each layer, you can use the `du -sh` command, which gives the size as a human-readable value. -```bash +```console $ ls -l /var/lib/docker/vfs/dir/ total 0 @@ -111,7 +111,7 @@ drwxr-xr-x. 21 root root 224 Aug 2 18:23 a292ac6341a65bf3a5da7b7c251e19de1294bd drwxr-xr-x. 21 root root 224 Aug 2 18:23 e92be7a4a4e3ccbb7dd87695bca1a0ea373d4f673f455491b1342b33ed91446b ``` -```bash +```console $ du -sh /var/lib/docker/vfs/dir/* 4.0K /var/lib/docker/vfs/dir/3262dfbe53dac3e1ab7dcc8ad5d8c4d586a11d2ac3c4234892e34bff7f6b821e diff --git a/storage/storagedriver/zfs-driver.md b/storage/storagedriver/zfs-driver.md index f34ee4ee38..9c7fc45b64 100644 --- a/storage/storagedriver/zfs-driver.md +++ b/storage/storagedriver/zfs-driver.md @@ -56,7 +56,7 @@ use unless you have substantial experience with ZFS on Linux. 2. Copy the contents of `/var/lib/docker/` to `/var/lib/docker.bk` and remove the contents of `/var/lib/docker/`. - ```bash + ```console $ sudo cp -au /var/lib/docker /var/lib/docker.bk $ sudo rm -rf /var/lib/docker/* @@ -67,7 +67,7 @@ use unless you have substantial experience with ZFS on Linux. have specified the correct devices, because this is a destructive operation. This example adds two devices to the pool. - ```bash + ```console $ sudo zpool create -f zpool-docker -m /var/lib/docker /dev/xvdf /dev/xvdg ``` @@ -75,7 +75,7 @@ use unless you have substantial experience with ZFS on Linux. display purposes only, and you can use a different name. Check that the pool was created and mounted correctly using `zfs list`. - ```bash + ```console $ sudo zfs list NAME USED AVAIL REFER MOUNTPOINT @@ -96,7 +96,7 @@ use unless you have substantial experience with ZFS on Linux. 4. Start Docker. Use `docker info` to verify that the storage driver is `zfs`. - ```bash + ```console $ sudo docker info Containers: 0 Running: 0 @@ -122,7 +122,7 @@ use unless you have substantial experience with ZFS on Linux. To increase the size of the `zpool`, you need to add a dedicated block device to the Docker host, and then add it to the `zpool` using the `zpool add` command: -```bash +```console $ sudo zpool add zpool-docker /dev/xvdh ``` diff --git a/storage/tmpfs.md b/storage/tmpfs.md index 6825f55bcc..c1247b58c4 100644 --- a/storage/tmpfs.md +++ b/storage/tmpfs.md @@ -72,7 +72,7 @@ second uses the `--tmpfs` flag.
-```bash +```console $ docker run -d \ -it \ --name tmptest \ @@ -83,7 +83,7 @@ $ docker run -d \
-```bash +```console $ docker run -d \ -it \ --name tmptest \ @@ -105,7 +105,7 @@ tmptest` and looking for the `Mounts` section: Remove the container: -```bash +```console $ docker container stop tmptest $ docker container rm tmptest @@ -125,7 +125,7 @@ as the `--tmpfs` flag does not support them. The following example sets the `tmpfs-mode` to `1770`, so that it is not world-readable within the container. -```bash +```console docker run -d \ -it \ --name tmptest \ diff --git a/storage/troubleshooting_volume_errors.md b/storage/troubleshooting_volume_errors.md index 388af6411c..e6b3f4c512 100644 --- a/storage/troubleshooting_volume_errors.md +++ b/storage/troubleshooting_volume_errors.md @@ -18,7 +18,7 @@ documentation for `cadvisor` instructs you to run the `cadvisor` container as follows: -```bash +```console $ sudo docker run \ --volume=/:/rootfs:ro \ --volume=/var/run:/var/run:rw \ @@ -53,7 +53,7 @@ If you are unsure which process is causing the path mentioned in the error to be busy and preventing it from being removed, you can use the `lsof` command to find its process. For instance, for the error above: -```bash +```console $ sudo lsof /var/lib/docker/containers/74bef250361c7817bee19349c93139621b272bc8f654ae112dd4eb9652af9515/shm ``` diff --git a/storage/volumes.md b/storage/volumes.md index a90cbc7b1d..eb214690d0 100644 --- a/storage/volumes.md +++ b/storage/volumes.md @@ -110,13 +110,13 @@ container. **Create a volume**: -```bash +```console $ docker volume create my-vol ``` **List volumes**: -```bash +```console $ docker volume ls local my-vol @@ -124,7 +124,7 @@ local my-vol **Inspect a volume**: -```bash +```console $ docker volume inspect my-vol [ { @@ -140,7 +140,7 @@ $ docker volume inspect my-vol **Remove a volume**: -```bash +```console $ docker volume rm my-vol ``` @@ -161,7 +161,7 @@ after running the first one.
-```bash +```console $ docker run -d \ --name devtest \ --mount source=myvol2,target=/app \ @@ -171,7 +171,7 @@ $ docker run -d \
-```bash +```console $ docker run -d \ --name devtest \ -v myvol2:/app \ @@ -205,7 +205,7 @@ destination, and that the mount is read-write. Stop the container and remove the volume. Note volume removal is a separate step. -```bash +```console $ docker container stop devtest $ docker container rm devtest @@ -259,7 +259,7 @@ Docker for Azure both support persistent storage using the Cloudstor plugin. The following example starts a `nginx` service with four replicas, each of which uses a local volume called `myvol2`. -```bash +```console $ docker service create -d \ --replicas=4 \ --name devtest-service \ @@ -269,7 +269,7 @@ $ docker service create -d \ Use `docker service ps devtest-service` to verify that the service is running: -```bash +```console $ docker service ps devtest-service ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS @@ -278,7 +278,7 @@ ID NAME IMAGE NODE Remove the service, which stops all its tasks: -```bash +```console $ docker service rm devtest-service ``` @@ -313,7 +313,7 @@ The `--mount` and `-v` examples have the same end result.
-```bash +```console $ docker run -d \ --name=nginxtest \ --mount source=nginx-vol,destination=/usr/share/nginx/html \ @@ -323,7 +323,7 @@ $ docker run -d \
-```bash +```console $ docker run -d \ --name=nginxtest \ -v nginx-vol:/usr/share/nginx/html \ @@ -337,7 +337,7 @@ After running either of these examples, run the following commands to clean up the containers and volumes. Note volume removal is a separate step. -```bash +```console $ docker container stop nginxtest $ docker container rm nginxtest @@ -367,7 +367,7 @@ The `--mount` and `-v` examples have the same result.
-```bash +```console $ docker run -d \ --name=nginxtest \ --mount source=nginx-vol,destination=/usr/share/nginx/html,readonly \ @@ -377,7 +377,7 @@ $ docker run -d \
-```bash +```console $ docker run -d \ --name=nginxtest \ -v nginx-vol:/usr/share/nginx/html:ro \ @@ -408,7 +408,7 @@ correctly. Look for the `Mounts` section: Stop and remove the container, and remove the volume. Volume removal is a separate step. -```bash +```console $ docker container stop nginxtest $ docker container rm nginxtest @@ -448,7 +448,7 @@ host and can connect to the second using SSH. On the Docker host, install the `vieux/sshfs` plugin: -```bash +```console $ docker plugin install --grant-all-permissions vieux/sshfs ``` @@ -458,7 +458,7 @@ This example specifies a SSH password, but if the two hosts have shared keys configured, you can omit the password. Each volume driver may have zero or more configurable options, each of which is specified using an `-o` flag. -```bash +```console $ docker volume create --driver vieux/sshfs \ -o sshcmd=test@node2:/home/test \ -o password=testpassword \ @@ -472,7 +472,7 @@ configured, you can omit the password. Each volume driver may have zero or more configurable options. **If the volume driver requires you to pass options, you must use the `--mount` flag to mount the volume, rather than `-v`.** -```bash +```console $ docker run -d \ --name sshfs-container \ --volume-driver vieux/sshfs \ @@ -485,7 +485,7 @@ $ docker run -d \ This example shows how you can create an NFS volume when creating a service. This example uses `10.0.0.10` as the NFS server and `/var/docker-nfs` as the exported directory on the NFS server. Note that the volume driver specified is `local`. #### NFSv3 -```bash +```console $ docker service create -d \ --name nfs-service \ --mount 'type=volume,source=nfsvolume,target=/app,volume-driver=local,volume-opt=type=nfs,volume-opt=device=:/var/docker-nfs,volume-opt=o=addr=10.0.0.10' \ @@ -493,7 +493,7 @@ $ docker service create -d \ ``` #### NFSv4 -```bash +```console docker service create -d \ --name nfs-service \ --mount 'type=volume,source=nfsvolume,target=/app,volume-driver=local,volume-opt=type=nfs,volume-opt=device=:/var/docker-nfs,"volume-opt=o=addr=10.0.0.10,rw,nfsvers=4,async"' \ @@ -503,8 +503,8 @@ docker service create -d \ ### Create CIFS/Samba volumes You can mount a Samba share directly in docker without configuring a mount point on your host. -```bash -docker volume create \ +```console +$ docker volume create \ --driver local \ --opt type=cifs \ --opt device=//uxxxxx.your-server.de/backup \