Skip to content

Instantly share code, notes, and snippets.

@ksatirli
Created September 9, 2017 16:05
Show Gist options
  • Save ksatirli/23dbc5a086e851352e95a4a5e39ffeb5 to your computer and use it in GitHub Desktop.
Save ksatirli/23dbc5a086e851352e95a4a5e39ffeb5 to your computer and use it in GitHub Desktop.
Ansible: start Docker Container
---
-
name: interacting with Docker
hosts: localhost
strategy: free
gather_facts: true
vars:
docker_host_registry_path: "/Users/{{ lookup('env','USER') }}/Sites/_test.local/docker-registry"
docker_container_registry_name: registry
docker_container_registry_version: 2.6.1
tasks:
- name: Docker Registry
docker_container:
name: "{{ docker_container_registry_name }}"
env:
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: "Docker Registry on {{ ansible_hostname }}"
REGISTRY_AUTH_HTPASSWD_PATH: "/auth/htpasswd"
REGISTRY_HTTP_ADDR: "0.0.0.0:443"
REGISTRY_HTTP_TLS_CERTIFICATE: "{{ docker_host_registry_path }}/certs/domain.crt"
REGISTRY_HTTP_TLS_KEY: "{{ docker_host_registry_path }}/certs/domain.key"
hostname: docker-registry.withmethod.example
image: "registry:{{ docker_container_registry_version }}"
keep_volumes: true
published_ports:
- "5000:5000"
privileged: false
pull: true
read_only: true
restart: true
restart_policy: always
state: started
volumes:
- "{{ docker_host_registry_path }}/images:/var/lib/registry:rw"
- "{{ docker_host_registry_path }}/auth:/auth:ro"
register: docker_container_registry
- name: print information for Docker Registry container
debug:
msg: "{{ docker_container_registry.ansible_facts.docker_container }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment