provider/docker: Upload files into container before first start #9520
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is another attempt to implement a feature started by @ColinHebert in #4921.
The main difference from the original PR - Terraform operates with file content instead of filenames, this allows rendering files from templates, and detect changes on resource update.
Rationale
For example, private TLS-keys: they cannot be stored inside Docker image in a registry, so have to be copied into a specific container instance on start.
There is a practice to store such data in environment variables, but this approach still has limitations. Sometimes using plain files if preferable.
Most of the tools require text configuration files, like
nginx.conf
,elasticsearch.yml
, orinfluxdb.conf
. Even if dynamic data (like hostnames) is moved into environment variables, we still need to customize these files, and overwrite defaults stored inside an official image. Current solutions are:But this approach significantly complicates a workflow.
Better, but does not allow to control versions of the data.
Solution
docker_container
resource gets a newupload
block.Configuration files are copied into a created container before it's started.
It works the same way as Docker client:
There was an idea of a provisioner for Docker containers, suggested in #6216 and #6827, but this is a different feature, and cannot be used for the use cases described here.