Moving Docker images to a new repo
WARNING, before starting this process, make sure you have the very latest azure cli installed and have logged into azure by performing a az login from the cli
az cli can be found here: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?view=azure-cli-latest
This can now all be done from your local machine
1. curl -u jenkins:jenkins https://repository.tis.nhs.uk:5000/v2/hee/{{ docker image name }}/tags/list replace {{ docker image name }} with the desiered docker image
2. This will give you a list of all the tags like this:
curl -u jenkins:jenkins https://repository.tis.nhs.uk:5000/v2/hee/intrepid-dr-etl/tags/list
{"name":"hee/intrepid-dr-etl","tags":["1.0.8-21","1.0.9-26","1.4.12.Final","1.4.24.Final","1.4.4-58","1.0.2.Final","1.4.11.Final","1.4.13-67","1.4.16.Final","1.4.8-61","1.3.5-55","1.1.10.Final","1.1.14-47","1.3.4-54","1.4.1-56","1.4.15-68","1.4.16-69","1.4.18.Final","04bf3073aec9df7767f11967a1416b5654a4085b","333057cc9804bda6cb8cf09101fd22bfb5d6c90f","1.4.22-76","1.1.7-37","1.1.8-40","1.1.8-41","1.3.4.Final","1.4.15.Final","1.0.6-19","1.4.22.Final","1.1.1-29","1.0.8.Final","1.3.0-48","1.4.10-63","544d964a1d1764d1594fb087611da68b920a45c4","1.0.2-15","1.0.9-24","1.4.11-64","1.4.17.Final","1.4.23.Final","1.0.2-14","1.0.5-18","1.1.14-45","1.1.7-38","1.4.12-66","latest","1.0.10-27","1.4.17-70","1.4.25.Final","1.1.10-43","1.0.7-20","1.0.9.Final","1.1.2-30","1.1.3-31","1.1.4-32","1.3.2-50","1.4.18-71","1.0.1-13","1.4.26.Final","1.4.9-62","1.4.19.Final","1.1.5-33","1.1.8-42","1.3.0.Final","1.3.3-51","1.1.14-46","1.4.1.Final","1.0.8-23","1.1.14.Final","1.1.7-39","1.3.4-53","1.4.19-72","1.1.14-44","1.1.6-35","1.3.5.Final","1.4.12-65","1.4.21.Final","1.4.4.Final","1.0.3-16","1.0.9-25","1.3.4-52","1.4.10.Final","1.4.21-74","1.0.8-22","1.1.7-36","1.4.13.Final","1.4.22-75","0eea47ae4670c62858a96dcb05e571bde0dacb85"]}
3. Convert the tags using the following transformations by doing the following (you can do this with find and replace in atom as you can enable find and replace regex)
find , and replace with \n
find ^" and replace with – intrepid-dr-etl: (change this to the name of the container your copying)
find " and replace with nothing
this should give you a list like this (but probably longer):
- intrepid-dr-etl:1.0.8-21
- intrepid-dr-etl:1.0.9-26
- intrepid-dr-etl:1.4.12.Final
- intrepid-dr-etl:1.4.24.Final
- intrepid-dr-etl:1.4.4-58
- intrepid-dr-etl:1.0.2.Final
- intrepid-dr-etl:1.4.11.Final
- intrepid-dr-etl:1.4.13-67
- intrepid-dr-etl:1.4.16.Final
- intrepid-dr-etl:1.4.8-61
- intrepid-dr-etl:04bf3073aec9df7767f11967a1416b5654a4085b
- intrepid-dr-etl:333057cc9804bda6cb8cf09101fd22bfb5d6c90f
- intrepid-dr-etl:1.4.22-76
4. Open the tis-devops repo and go to ansible/tasks
open the playbook called docker-container-move.yml
replace all of the "with_items" with what you’ve just exported:
- name: Docker container move
hosts: localhost
tasks:
- name: docker container import to acr
shell: "az acr import --name heetiscontainerregistry --source repository.tis.nhs.uk/hee/{{ item }} --image {{ item }} --username jenkins --password jenkins"
with_items:
- intrepid-dr-etl:1.3.0-48
- intrepid-dr-etl:1.4.10.Final
- intrepid-dr-etl:1.0.3-16
- intrepid-dr-etl:1.1.7-36
- intrepid-dr-etl:1.1.14-44
- intrepid-dr-etl:1.4.17-70
- intrepid-dr-etl:1.4.26.Final
- intrepid-dr-etl:544d964a1d1764d1594fb087611da68b920a45c4
- intrepid-dr-etl:1.0.5-18
- intrepid-dr-etl:1.0.9-25
- intrepid-dr-etl:1.1.14-47
Then just run the playbook by running the following playbook:
ansible-playbook -i ../inventory/dev docker-container-move.yml
(this is providing you are in the tis-devops/ansible/tasks directory)
Wait for the playbook to finish and you’ll have everything in the new registry.
Slack: https://hee-nhs-tis.slack.com/
Jira issues: https://hee-tis.atlassian.net/issues/?filter=14213