DEPRECATED: This functionality has found it's way into the main packer binary. This repo is no longer maintained.
This is a Packer post-processor plugin which allows setting Docker metadata on an artifact from the docker-tag post-processor.
Normally, Docker images built using Packer cannot include entrypoint, cmd, user, environment variables and other metadata that is available in Dockerfiles. This plugin will create a temporary Dockerfile and run docker build
in an annonymous context. Most Dockerfile instructions are supported as json parametersp
RUN
,ADD
,COPY
, andONBUILD
are not supported because packer provisioners should be used for their functionality.- Docker no longer supports digests in
FROM
, thus a chained docker-tag post-processor is required.
In your packer template, configure the post processor:
{
...
"post-processors": [
[
{
"type": "docker-tag",
"repository": "localhost/example"
},
{
"type": "docker-dockerfile",
"volume": ["/data"]
"expose": [8080],
"entrypoint": ["/entrypoint.sh"],
"cmd": ["bash"],
"env": {
"FOO": "bar"
}
}
]
]
...
}
cmd
and entrypoint
can have either array or string values, this mirrors the Dockerfile format and functionality
See the Dockerfile reference for details.
Install the necessary dependencies
$ go get -d ./...
To compile the Packer plugin, run go build
.
$ go build
Put the binary packer-post-processor-docker-dockerfile
into the bin
directory of your choice
This plugin was made possible by Shiftgig
This plugin is released under the Apache License, Version 2.0.
Please file an issue on the github repository if you think anything isn't working properly or an improvement is required.
This plugin was developed against Docker 1.8.1 and Packer 0.8.6.