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

provider/docker: Add extra_hosts parameter for containers #3463

Merged
merged 2 commits into from
Jan 15, 2016

Conversation

paulbellamy
Copy link
Contributor

Usage, as in:

resource "docker_container" "example" {
  image = "alpine"
  name = "example"
  command = ["cat", "/etc/hosts"]
  extra_hosts = {
    host = "www.example.com"
    ip = "192.168.1.1"
  }
}

It's equivalent to the docker command-line --add-host host:ip flag, but I've opted for the docker API version (called ExtraHosts), as I feel it works better syntactically.

@@ -101,6 +101,14 @@ func resourceDockerContainer() *schema.Resource {
Set: resourceDockerPortsHash,
},

"extra_hosts": &schema.Schema{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a set, it's valid to have multiple instances of it. Might this be better named extra_host (singular) or even host such that the set semantics read better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be more in favour of hosts, so that it matches ports and volumes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for consistency.

@jen20
Copy link
Contributor

jen20 commented Dec 2, 2015

Hi @paulbellamy! Thanks for submitting this. I've left a few comments in line, could you let me know your thoughts on them?

@jen20
Copy link
Contributor

jen20 commented Dec 2, 2015

Hi @paulbellamy! I've replied to your comments inline. I merged quite a bit into the docker container resource today, so if you could rebase your work onto master that would be great.

@paulbellamy
Copy link
Contributor Author

Cool, applied changes and rebased. I also inlined ports and volumes schemas, for consistency.

@jen20 jen20 merged commit 52d178b into hashicorp:master Jan 15, 2016
@jen20
Copy link
Contributor

jen20 commented Jan 15, 2016

Thanks @paulbellamy! I pulled this locally and added some acceptance tests. The only other change I made was to rename hosts to host in the schema - which reads more naturally when you define more than one of them. I'll go back shortly and look at whether everything else in the docker provider matches that pattern also. Thanks for the contribution - sorry it took so long to merge!

@paulbellamy paulbellamy deleted the docker-extra-hosts branch January 15, 2016 12:00
@ghost
Copy link

ghost commented Apr 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants