Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom nameserver to Docker container #1095

Closed
asg1612 opened this issue Jan 19, 2018 · 4 comments
Closed

Add custom nameserver to Docker container #1095

asg1612 opened this issue Jan 19, 2018 · 4 comments

Comments

@asg1612
Copy link
Contributor

asg1612 commented Jan 19, 2018

Issue Type

  • Feature request

Molecule and Ansible details

ansible 2.4.2.0
molecule, version 2.7.0
  • Molecule installation method: pip
  • Ansible installation method: pip

Desired Behaviour

I need configure a custom nameserver into a docker container. (/etc/resolv.conf)
When I run a container manually, I insert the nameserver like this:

  • sudo docker run --dns=192.168.1.100 -d nginx

How can I add the nameserver with molecule.yml file?

@dj-wasabi
Copy link
Contributor

What you can do is, first updating the create.yml file by adding the following line:

dns_servers: "{{ dns_servers.links | default(omit) }}"

to the Create molecule instance(s) task.

In molecule.yml, you can use something like this:

  - name: my_host
    groups:
      - my_fancy_group
    image: milcom/centos7-systemd
    networks:
      - name: container
    dns_servers:
      - 192.168.1.100

When you execute a molecule test, the container(s) will be created with the dns option.

@retr0h
Copy link
Contributor

retr0h commented Jan 19, 2018

Thanks @dj-wasabi

Or if you don't feel like setting through molecule.yml you can simply hard code it in create.yml. The whole point of create.yml was to provide flexibility to people to do things the way they felt best.

In the case for docker, we seem to be adding most settings to molecule.yml. However, the more complex drivers (ec2, gce, openstack) most of the create.yml woud be customized by the user.

@retr0h
Copy link
Contributor

retr0h commented Jan 19, 2018

Also, feel free to submit a PR to add this functionality, so others may benefit.

asg1612 added a commit to asg1612/molecule that referenced this issue Jan 19, 2018
@asg1612 asg1612 closed this as completed Jan 19, 2018
@asg1612
Copy link
Contributor Author

asg1612 commented Jan 19, 2018

Thanks @dj-wasabi

It's works with a modification:
dns_servers: "{{ item.dns_servers | default(omit) }}"

I created a PR with the modification

I closed the issue wrongly

retr0h pushed a commit that referenced this issue Jan 22, 2018
* Add custom nameserver to Docker container #1095

* add new files to custom nameserver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants