Docker volume commands

To list docker volumes

docker volume ls

To create a volume

docker volume create {VOLUME_NAME}

To remove a specific volume

docker volume rm {VOLUME_NAME}

To remove volumes not linked to a host

docker volume prune

To inspect a specific volume

docker volume inspect {VOLUME_ID}

To specify a custom name for a volume (ex: with mysql container)

docker container run -d --name mysql  
-e MYSQL_ALLOW_EMPTY_PASSWORD=true -v {CUSTOM_NAME}:{CONTAINER_PATH}

For bind mounting

docker container run -d --name nginx -p 80:80 -v {HOST_PATH}:{CONTAINER_PATH}
Previous
Next