# show docker volume info docker volume ls DRIVER VOLUME NAME local jenkins_home local yakir-test # how to use # default volume, directory = /var/lib/docker/volumes/ -v yakir-test:/container-app/my-app --volume yakir-test:/container-app/my-app --mount # bind mounts -v /local_path/app.conf:/container-app/app.conf --volume /local_path/app.conf:/container-app/app.conf --mount # memory volume --tmpfs
# stop docker systemctl stop docker.service # backup and empty contents cp -au /var/lib/docker/ /var/lib/docker.bk rm -rf /var/lib/docker/* # format block device as a btrfs filesystem mkfs.btrfs -f /dev/xvdf # mount the btrfs filesystem on /var/lib/docker mount point mount -t btrfs /dev/xvdf /var/lib/docker cp -au /var/lib/docker.bk/* /var/lib/docker/ # configure Docker to use the btrfs storage driver vim /etc/docker/daemon.json { "storage-driver": "btrfs" } systemctl start docker.service # verify docker info --format '{{ json .Driver }}' "btrfs"
# stop docker systemctl stop docker.service # backup and empty contents cp -au /var/lib/docker/ /var/lib/docker.bk rm -rf /var/lib/docker/* # options: separate backing filesystem, mount into /var/lib/docker and make sure to add mount to /etc/fstab to make it. # configure Docker to use the btrfs storage driver vim /etc/docker/daemon.json { "storage-driver": "overlay2" } systemctl start docker.service # verify docker info --format '{{ json .Driver }}' "overlay2" mount |grep overlay |grep docker
# stop docker systemctl stop docker.service # backup and empty contents cp -auR /var/lib/docker/ /var/lib/docker.bk rm -rf /var/lib/docker/* # create a new zpool on block device and mount into /var/lib/docker zpool create -f zpool-docker -m /var/lib/docker /dev/xvdf # add zpoll zpool add zpool-docker /dev/xvdh # verify zpool zfs list NAME USED AVAIL REFER MOUNTPOINT zpool-docker 55K 96.4G 19K /var/lib/docker # configure Docker to use the btrfs storage driver vim /etc/docker/daemon.json { "storage-driver": "zfs" } systemctl start docker.service # verify docker info --format '{{ json .Driver }}' "zfs"
containerd snapshotters
1 2 3 4 5 6 7 8 9 10 11 12 13
# configure Docker to use the btrfs storage driver vim /etc/docker/daemon.json { "features": { "containerd-snapshotter": true } } systemctl restart docker.service # verify docker info -f '{{ .DriverStatus }}' [[driver-type io.containerd.snapshotter.v1]]
Networking
Overview
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# show docker network info docker network ls NETWORK ID NAME DRIVER SCOPE b2adc1fcf214 bridge bridge local 2ed9fbc8db3e host host local f1b2d749ed2c none null local # how to use # bridge --net bridge # host --net host # none --net none # container --net container:container_name|container_id