- Docker and Kubernetes for Java Developers
- Jaroslaw Krochmalski
- 256字
- 2021-07-02 18:44:54
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.
- Web前端開發(fā)技術(shù):HTML、CSS、JavaScript(第3版)
- What's New in TensorFlow 2.0
- Learning Selenium Testing Tools with Python
- 動手玩轉(zhuǎn)Scratch3.0編程:人工智能科創(chuàng)教育指南
- C#程序設(shè)計(慕課版)
- C語言程序設(shè)計
- Jupyter數(shù)據(jù)科學(xué)實戰(zhàn)
- 零基礎(chǔ)Java學(xué)習(xí)筆記
- AIRIOT物聯(lián)網(wǎng)平臺開發(fā)框架應(yīng)用與實戰(zhàn)
- Mastering Unity 2D Game Development(Second Edition)
- Android移動應(yīng)用項目化教程
- 計算語言學(xué)導(dǎo)論
- Java EE輕量級解決方案:S2SH
- 一覽眾山小:ASP.NET Web開發(fā)修行實錄
- Learning RxJava