To delete all containers including its volumes use,
docker rm -vf $(docker ps -a -q)
To delete all the images,
docker rmi -f $(docker images -a -q)
Remember, you should remove all the containers before removing all the images from which those containers were created.
In case you are working on Windows (Powershell),
$images = docker images -a -q
foreach ($image in $images) { docker image rm $image -f }
bind volume
docker run -v host_foler:absolute_path_of_foler_in_image image_name
如何查运行中的container:
# find ID of your running container:
docker ps
# create image (snapshot) from container filesystem
docker commit 12345678904b5 mysnapshot
# explore this filesystem using bash (for example)
docker run -t -i mysnapshot /bin/bash
There are multiple ways to achieve that:
修改内容:
You can enter the container by running the command:
docker exec -it bash
Note however depending on the container you may not have a simple text editor..
把container中的文件拷贝出来
Another alternative would be to copy the file you want to edit from the container onto your host by running:
docker cp :/path/to/file/in/container .
Edit the file and then copy it back into the container:
docker cp :/path/to/file/in/container
Third option is to create a bind mount which will effectively expose the file from the container onto the host
1. docker run -v $(pwd)/files:/dir/containing/file/in/container ...
2. docker run --mount type=bind,source="$(pwd)"/data,target=/home/data -it
1. This will expose the container folder in the "files" directory, and you can edit the file in the host and it will be directly reflected inside the container.
2. Note "-it conainter_name" should be the last flags
https://techoverflow.net/2013/10/22/docker-remove-all-images-and-containers
https://linuxize.com/post/how-to-remove-docker-images-containers-volumes-and-networks/
https://stackoverflow.com/questions/20813486/exploring-docker-containers-file-system