Docker Volumes Management: Difference between revisions
From WikiMLT
m Стадий: 4 [Фаза:Авторизиране, Статус:Разработен]; Категория:Containers |
m Стадий: 5 [Фаза:Утвърждаване, Статус:Авторизиран]; Категория:Containers |
||
Line 81: | Line 81: | ||
| Прндл = Containers | | Прндл = Containers | ||
| Прндл1 = DevOps_and_SRE | | Прндл1 = DevOps_and_SRE | ||
| Стадий = | | Стадий = 5 | ||
| Фаза = | | Фаза = Утвърждаване | ||
| Статус = | | Статус = Авторизиран | ||
| ИдтПт = Spas | | ИдтПт = Spas | ||
| РзбПт = Spas | | РзбПт = Spas | ||
| АвтПт = {{REVISIONUSER}} | | АвтПт = Spas | ||
| УтвПт = {{REVISIONUSER}} | |||
| ИдтДт = 24.05.2023 | | ИдтДт = 24.05.2023 | ||
| РзбДт = 24.05.2023 | | РзбДт = 24.05.2023 | ||
| АвтДт = {{Today}} | | АвтДт = 24.05.2023 | ||
| УтвДт = {{Today}} | |||
| ИдтРв = [[Special:Permalink/32547|32547]] | | ИдтРв = [[Special:Permalink/32547|32547]] | ||
| РзбРв = [[Special:Permalink/32557|32557]] | | РзбРв = [[Special:Permalink/32557|32557]] | ||
| АвтРв = {{REVISIONID}} | | АвтРв = [[Special:Permalink/32558|32558]] | ||
| УтвРв = {{REVISIONID}} | |||
}} | }} | ||
</div> | </div> | ||
</noinclude> | </noinclude> |
Revision as of 09:52, 24 May 2023
Basic commands
docker volume
Usage: docker volume COMMAND
Manage volumes
Commands:
create Create a volume
inspect Display detailed information on one or more volumes
ls List volumes
prune Remove all unused local volumes
rm Remove one or more volumes
Run 'docker volume COMMAND --help' for more information on a command.
docker volume create volume_name
docker volume ls
docker volume inspect volume_name
sudo ls -la /var/lib/docker/volumes/
docker volume (rm|prune) volume_name
Explanations
Note when you are using docker compose
, unless specify path in the left side on the services:
container-name:
volumes:
section docker will automatically create a volume /var/lib/docker/volumes/
named after the container-name underscore _ and the name of the volume.
Examples
example 1
docker-compose.yml
version: "3"
services:
container-name:
image: image_name
volumes:
- ./base:/data
The directory used as a volume is "./base" within the current directory where the "docker-compose.yml" is located.
example 2
docker-compose.yml
version: "3"
services:
container-name:
image: image_name
volumes:
- base:/data
volumes:
base:
The directory used as a volume is "/var/lib/docker/volumes/container-name_base/_data" and it will be automatically created unles some additional options are specified within the "volumes:" section.
References
- Docker: Reference > Compose file reference > Compose specification > Volumes top-level element