Docker cannot be modified once the container is generated

Solution:

  1. Save the container as an image
  2. Back up GitLab and rebuild the container

Plan 2 is adopted this time.

To start backup

  1. Into the container
docker exec -it gitlab bash
Copy the code
  1. Generate the backup
gitlab-rake gitlab:backup:create
Copy the code
  1. Exit the container and copy the backup
Docker cp gitlab: / var/opt/gitlab/backups / 1625645210 _2021_07_07_13. 11.3 _gitlab_backup. Tar/User/MACCopy the code

Look at the container generation instructions

  1. Download runlike
pip install runlike
Copy the code
  1. See instructions
runlike -p gitlab
Copy the code
  1. After copying, modify the instruction port
docker run \ --name=gitlab \ ...... .Copy the code

Regenerate the container

  1. Back up the container and delete it

2. Use the modified command

docker run \ --name=gitlab \ ...... .Copy the code

Restore the backup

  1. Into the container
docker exec -it gitlab bash

Copy the code
  1. Stop related data connection services
gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq

Copy the code
  1. Modify the permission. If the server is restored from the local server, the permission is not changed
Chmod 777 / var/opt/gitlab/backups / 1625645210 _2021_07_07_13. 11.3 _gitlab_backup. TarCopy the code
  1. Restore by number
Gitlab - rake gitlab: backup, restore backup = 1625645210 _2021_07_07_13. 11.3Copy the code
  1. Type Yes twice as prompted and press Enter

  1. Restart the Docker, and the browser accesses the address of the new server to view the migration

conclusion

In fact, it is safer to use scheme 1 directly, because scheme 2 May fail.