-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Using packer to build lightweight go based docker containers #1902
Comments
Agree, it would be great if packer cloud use the @i0n Could you provide a sample config for this? |
Sure. Do you mean what the packer.json would look like to provision a container like this? I imagine something like:
|
After some digging I found the following issues:
Which is not true. The {
"builders": [
{
"type": "docker",
"image": "tianon/true",
"export_path": "image.tar",
"pull": "true",
"run_command": [
"-d", "-i", "-t", "{{.Image}}", "/true"
]
}
],
"provisioners": [
{
"type": "file",
"source": "go-program",
"destination": "/bin/app"
}
]
} This running this works if the file-provisioner is omited, but with it fails with:
|
I think this should be fixed as part of the docker API in #4186 |
Hi chaps.
Admittedly I haven't done a huge amount of poking around on this issue, but I have a theory.
Use case:
Use packer to build a docker container from the 'scratch' base image. This is all you need to run a statically linked go binary.
Problem:
When using the file provisioner, packer seems to be attempting to use /bin/bash inside the container (which in the case of scratch base image doesn't exist).
Tests:
Using a standard Dockerfile works perfectly (COPY)
Using a "normal" base image (like ubuntu) with packer works perfectly.
Question:
It is of course perfectly possible to achieve the desired docker image without using packer, but I wondered if this is a known issue or simply a use case that has slipped through the net?
Why?
The difference is pretty big: My test container (with a small simple go binary) ballooned from 7.3mb when using scratch to 195.7mb when forced to use ubuntu base image.
The text was updated successfully, but these errors were encountered: