Docker Volumes Management: Difference between revisions

From WikiMLT
m (Стадий: 4 [Фаза:Авторизиране, Статус:Разработен]; Категория:Containers)
m (Стадий: 5 [Фаза:Утвърждаване, Статус:Авторизиран]; Категория:Containers)
Line 79: Line 79:
  | Прндл  = Containers
  | Прндл  = Containers
  | Прндл1 = DevOps_and_SRE
  | Прндл1 = DevOps_and_SRE
  | Стадий = 4
  | Стадий = 5
  | Фаза  = Авторизиране
  | Фаза  = Утвърждаване
  | Статус = Разработен
  | Статус = Авторизиран
  | ИдтПт  = Spas
  | ИдтПт  = Spas
  | РзбПт  = Spas
  | РзбПт  = Spas
  | АвтПт  = {{REVISIONUSER}}
  | АвтПт  = Spas
  | УтвПт  = Spas
  | УтвПт  = {{REVISIONUSER}}
  | ИдтДт  = 24.05.2023
  | ИдтДт  = 24.05.2023
  | РзбДт  = 24.05.2023
  | РзбДт  = 24.05.2023
  | АвтДт  = {{Today}}
  | АвтДт  = 24.05.2023
  | УтвДт  = 24.05.2023
  | УтвДт  = {{Today}}
  | ИдтРв  = [[Special:Permalink/32547|32547]]
  | ИдтРв  = [[Special:Permalink/32547|32547]]
  | РзбРв  = [[Special:Permalink/32566|32566]]
  | РзбРв  = [[Special:Permalink/32566|32566]]
  | АвтРв  = {{REVISIONID}}
  | АвтРв  = [[Special:Permalink/32567|32567]]
  | РзАРв  = [[Special:Permalink/32558|32558]]
  | РзАРв  = [[Special:Permalink/32558|32558]]
| УтвРв  = {{REVISIONID}}
  | РзУРв  = [[Special:Permalink/32563|32563]]
  | РзУРв  = [[Special:Permalink/32563|32563]]
}}
}}
</div>
</div>
</noinclude>
</noinclude>

Revision as of 11:06, 24 May 2023

Ba­sic com­mands

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

Ex­pla­na­tions

Note when you are us­ing dock­er com­pose, un­less spec­i­fy path in the left side on the ser­vices: con­tain­er-name: vol­umes: sec­tion dock­er will au­to­mat­i­cal­ly cre­ate a vol­ume /​​​var/​​​lib/​​​do­ck­er/​​​vo­lu­mes/​​​ named af­ter the con­tain­er-name un­der­score _ and the name of the vol­ume.

Ex­am­ples

In Ex­am­ple 1 the con­tain­ers di­rec­to­ry :/​​​data will be bound (mount­ed) to the di­rec­to­ry ./​​​base with­in the cur­rent di­rec­to­ry where the docker-compose.yml is lo­cat­ed. In this case no vol­ume is spec­i­fied.

example 1
docker-compose.yml
version: "3"
services:
  container-name:
    image: image_name
    volumes:
    - ./base:/data

In Ex­am­ple 2 the di­rec­to­ry used as a vol­ume is /var/lib/­dock­er/vol­umes/­con­tain­er-name_base/ and it will be au­to­mat­i­cal­ly cre­at­ed un­less some ad­di­tion­al op­tions are spec­i­fied with­in the vol­umes: sec­tion. The ac­tu­al di­rec­to­ry :/​​​data of the con­tain­er will be bound to /var/lib/­dock­er/vol­umes/­con­tain­er-name_base/_­da­ta

example 2
docker-compose.yml
version: "3"
services:
  container-name:
    image: image_name
    volumes:
    - base:/data
volumes:
  base:

Ref­er­ences