# Test push and pull from the standard registry - name: Start the registry shell: cmd: docker-compose up -d chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Print list of images command: docker image ls --all --digests --no-trunc register: image_list failed_when: "'test/image' in image_list.stdout" - name: Copy the test image into local docker image storage command: > skopeo copy docker-archive:{{ workspace }}/test.img docker-daemon:localhost:9000/test/image:latest - name: Log in to registry command: docker login localhost:9000 -u testuser -p testpass - name: Push the test image to the registry # Use a lot of concurrency to check registry with concurrent pushes shell: printf "1\n2\n3\n4\n" | xargs -P 4 -I DNE docker push localhost:9000/test/image args: executable: /bin/bash - name: Remove the test image from the local cache command: docker rmi localhost:9000/test/image - name: Print list of images command: docker image ls --all --digests --no-trunc register: image_list failed_when: "'test/image' in image_list.stdout" - name: Pull the image from the registry command: docker pull localhost:9000/test/image - name: Print list of images command: docker image ls --all --digests --no-trunc register: image_list failed_when: "'test/image' not in image_list.stdout" - name: Try to pull an image that does not exist command: docker pull localhost:9000/test/dne register: result failed_when: result.rc != 1 - name: Remove the test image from the local cache command: docker rmi localhost:9000/test/image - name: Pull down the manifest for Alpine command: docker manifest inspect docker.io/library/alpine:3 register: _docker_manifest_inspect - name: Generate facts containing all the manifest tags set_fact: _alpine_tags: amd64: "{{ _docker_manifest_inspect.stdout | trim | from_json | json_query('manifests[?platform.architecture == `amd64`].digest') | first }}" arm64: "{{ _docker_manifest_inspect.stdout | trim | from_json | json_query('manifests[?platform.architecture == `arm64`].digest') | first }}" - name: Pull down an image for two different architectures command: docker pull docker.io/library/alpine@{{ item.value }} with_dict: "{{ _alpine_tags }}" - name: Retag both images and upload them to Zuul registry command: docker tag docker.io/library/alpine@{{ item.value }} localhost:9000/alpine:3-{{ item.key }} with_dict: "{{ _alpine_tags }}" - name: Push both retagged images command: docker push localhost:9000/alpine:3-{{ item.key }} with_dict: "{{ _alpine_tags }}" - name: Create a manifest with multi architecture images command: docker manifest create localhost:9000/alpine:3 localhost:9000/alpine:3-amd64 localhost:9000/alpine:3-arm64 - name: Wipe all images from the local cache (tagged in DockerHub) command: docker rmi docker.io/library/alpine@{{ item.value }} with_dict: "{{ _alpine_tags }}" - name: Wipe all images from the local cache (tagged in the registry) command: docker rmi {{ item }} loop: - localhost:9000/alpine:3-amd64 - localhost:9000/alpine:3-arm64 - name: Stop the registry shell: cmd: docker-compose down chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test" - name: Clean up docker volumes command: docker volume prune -f - name: Log out of registry command: docker logout localhost:9000