Here are my instructions for running the container:
docker run -p 5432:5432 --name=db -e POSTGRES_PASSWORD=secret -d --mount type=volume,src=postgres_data,target=/var/lib/postgresql/data postgres
docker volume ls
Here is the result:
0
And I verify that the container is running properly
And excute the
docker rm --help
command then prompts me that this cmmand can remove the anonymous volume associated with the container:
1
Then I do this:
docker stop db
docker rm -v db
docker ps -a
Here is the result:
2
Although the container has been removed, the volume is still there and I don’t understand why:
docker volume ls
3
remove a container also removes the volume associated with the container
New contributor
季天成 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.