I have multiple named volumes created with the following docker-compose:
gitlab:
restart: always
image: gitlab/gitlab-ee:latest
volumes:
- gitlab-config:/etc/gitlab
- gitlab-log:/var/log/gitlab
- gitlab-data:/var/opt/gitlab
volumes:
gitlab-config:
driver: local
driver_opts:
type: none
o: bind
device: /srv/docker-compose/volumes/gitlab-config
gitlab-log:
driver: local
driver_opts:
type: none
o: bind
device: /srv/docker-compose/volumes/gitlab-log
gitlab-data:
driver: local
driver_opts:
type: none
o: bind
device: /srv/docker-compose/volumes/gitlab-data
I want to change the device:
value on each volume without loosing data within those volumes.
If I simply do docker-compose down
, copy the directory specified in the device
to the new location (/new-path/volumes/gitlab-data
) and change yaml to point to that new location (device: /new-path/volumes/gitlab-data
), then, after docker-compose up -d
receiving the following error:
ERROR: Configuration for volume gitlab-config specifies "device" driver_opt /srv/docker-compose/volumes/gitlab-config, but a volume with the same name uses a different "device" driver_opt (/srv/docker-compose/volumes/redmine-mariadb-data). If you wish to use the new configuration, please remove the existing volume "project_gitlab-config" first:
$ docker volume rm project_gitlab-config
What is the correct way of backing up those volumes and changing the volumes' paths without loosing the data within those volumes?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…