wangsha.docker-generic-image

docker-generic-image

Build Status
Ansible Galaxy

This is an Ansible role to help manage and run a Docker container from any image you choose.

Requirements

This role has been tested only on Ubuntu 14.04. Since it uses Ansible's Docker module, make sure you have a recent version of docker-py and docker installed.

Examples

To install this module from Ansible Galaxy into the ./roles directory, run:

ansible-galaxy install wangsha.docker-generic-image -p ./roles

You can use it in a playbook like this, assuming Docker is already set up:

- hosts: 'servers'
  roles:
    - role: angstwad.docker_ubuntu
      become: true
    - role: wangsha.docker-generic-image
      become: true
      docker_container_name: hello-world
      docker_container_image: hello-world

Check the defaults/main.yml file for role variables that you can change.

If you need a playbook to set up Docker, check out the angstwad.docker_ubuntu Galaxy role.

Custom Volume Mappings

Docker lets you mount a directory or a file from the host system as a data volume. This role allows you to mount host directories to keep container data and host files to configure how the container behaves.

You can control volume mappings using docker_generic-image_directory_volumes and docker_generic-image_file_volumes. If you want to change the mappings, follow this format: <host directory>:<container directory>:<mapping mode>, making sure the host directories exist before launching containers.

To change host file mappings, update docker_generic-image_file_volumes. The role will create any necessary parent directories and copy the template to the host machine. The template should be named <host_file_name>.<host_file_extension>.j2. If you want to copy a template from your own Ansible directories, set docker_generic-image_template_path.

Example Config:

docker_container_file_volumes:
  - '/opt/myapp/conf/settings.conf:/etc/myapp/conf/settings.conf:ro'
docker_container_template_path: /path/to/ansible/project/templates/
# Ensure the file /path/to/ansible/project/templates/settings.conf.j2 exists.

Additional References

License

MIT

Author Information

  • wangsha
Informazioni sul progetto

Ansible role to install a given docker image.

Installa
ansible-galaxy install wangsha.docker-generic-image
Licenza
mit
Download
262
Proprietario