summaryrefslogtreecommitdiff
path: root/roles/docker/alpine-registry.yml
blob: 4c9c108a9359ebe67c58fa601ab2e9fa36e3cbc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
- name: Install Docker Registry on Alpine LXC Container
  hosts: docker_alpine_lxc

  vars_files:
    - ../variables.yml

  tasks:

    - name: Including docker bootstrap for alpine
      include: alpine.yml

    - name: Creating docker registry folder
      file:
        path: /opt/docker/registry
        state: directory

    - name: Working around docker registry not restarting after reboot
      blockinfile:
        path: /etc/local.d/2-docker-registry.start
        block: |
          while true;
          do
            [ -e /run/docker.sock ] && break;
            sleep 3;
          done
          docker stop $(docker ps -aq);
          docker container prune --force;
          docker run -d \
          --publish=5000:5000 \
          --volume=/opt:/var/lib/registry \
          --env=REGISTRY_HTTP_SECRET={{ secret_key }} \
          --restart=always \
          --name=registry \
          registry:{{ docker_registry_version }} \
        create: yes

    - name: Setting rc.local executable
      file:
        path: /etc/local.d/2-docker-registry.start
        mode: '0755'

    - name: Starting docker registry
      service:
        name: local
        state: restarted
        enabled: yes