Note: Take this post and pinch of salt, this is for personal reference and copy pasted commands. Will improve and update this post later.
Docker volume:
Two types
docker run -it —name test2 -v ~/somepath/data:/data ubuntu bash
docker run -it —name test2(name_of_container) -v ~/somepath/data(host_dir):/data(container_dir) ubuntu(image_name) bash(start bash)
Advantages of docker volume
A new volume’s contents can be pre-populated by a container.
docker volume create my-vol
docker run -it —name test2 -v data:/data ubuntu bash
docker run -it —name test2 -v data(docker volume name):/data(container-dir) ubuntu bash
docker volume ls
docker volume —help
docker volume rm data
docker run -it —name slave1 —volume-from master ubuntu bash
docker run -it —name slave1(new_container_name) —volume-from master(old_container_name) ubuntu bash
Reference: