mhutter / ansible-docker-systemd-service

Ansible role for creating Systemd services for docker containers
https://galaxy.ansible.com/mhutter/docker-systemd-service
MIT License
49 stars 30 forks source link

Add support for docker's '--network' flag #38

Closed andygrunwald closed 2 years ago

andygrunwald commented 2 years ago

Adding support for docker network settings

Example configuration:

- name: Start MySQL database
  include_role:
    name: docker-systemd-service
  vars:
    container_name: "name"
    container_image: "mysql:8.0.23"

    container_volumes:
      - '{{ mysql_container_volume_host_path }}:/var/lib/mysql:rw'

    # Export database port on localhost
    container_ports:
      - '127.0.0.1:3306:3306'

    container_network: "my-network-name"

    container_env:
      MYSQL_ROOT_PASSWORD: "{{ mysql_root_password }}"
      MYSQL_DATABASE: "{{ mysql_database }}"