官术网_书友最值得收藏!

Removing a volume

The same as with creating volumes, there are two ways of removing a volume in Docker. Firstly, you can remove a volume by referencing a container's name and executing the docker rm -v command:

$ docker rm -v <containerName or ID>  

Docker will not warn you, when removing a container without providing the -v option, to delete its volumes. As a result, you will have dangling volumes—volumes that are no longer referenced by a container. As you remember, they are easy to get rid of using the docker volume prune command.

Another option to remove the volume is by using the docker volume rm command:

$ docker volume rm <volumeName or ID>  

If the volume happens to be in use by the container, Docker Engine will not allow you to delete it and will give you a warning message:

As you can see, creating, sharing, and removing volumes in Docker is not that tricky. It's very flexible and allows the creating a setup you will need for your applications. But there's more to this flexibility. When creating a volume, you can specify a --driver option (or -d for short), which may be useful if you need to map some external, not so standard storage. The volumes we have created so far were using the local filesystem driver (the files were being stored on the local drive of the host system); you can see the driver name when inspecting a volume using the volume inspect command. There are other options though—let's look at them now.

主站蜘蛛池模板: 防城港市| 厦门市| 阿鲁科尔沁旗| 玉屏| 安多县| 固镇县| 左权县| 上饶县| 区。| 临猗县| 东乌| 承德县| 将乐县| 广饶县| 林芝县| 勐海县| 肥西县| 贵州省| 福海县| 五莲县| 武城县| 正宁县| 双鸭山市| 商都县| 深水埗区| 淅川县| 云阳县| 日土县| 仁化县| 凤翔县| 疏附县| 库尔勒市| 盱眙县| 衡阳市| 北宁市| 恭城| 马尔康县| 陕西省| 错那县| 保靖县| 博客|