https://www.freecodecamp.org/news/where-are-docker-images-stored-docker-container-paths-explained/
https://www.docker.com/blog/how-to-use-the-official-nginx-docker-image/ [Example]
Docker Volumes
It is possible to add a persistent store to containers to keep data longer than the container exists or to share the volume with the host or with other containers. A container can be started with a volume by using the -v option:
$ docker run --name nginx_container -v /var/log nginx
$
docker inspect nginx_container
Adding Custom HTML
By default, Nginx looks in the /usr/share/nginx/html
directory inside of the container for files to serve. We need to get our html files into this directory. A fairly simple way to do this is use a mounted volume. With mounted volumes, we are able to link a directory on our local machine and map that directory into our running container.
docker run -it --rm -d -p 8080:80 --name web -v ~/site-content:/usr/share/nginx/html nginx
docker run -v /path/to/host/directory:/path/inside/the/container imageWhen a docker container is deleted,
volume is not deleted by itself, atleast not by default.
Clean up space used by Docker
It is recommended to use the Docker command to clean up unused containers. Container, networks, images, and the build cache can be cleaned up by executing:
$ docker system prune -a
Additionally, you can also remove unused volumes by executing:
$ docker volumes prune
No comments:
Post a Comment