Sorry I pointed to the wrong Labels..
$ cat docker-label.json
{
"builders": [
{
"type": "docker",
"image": "ubuntu:16.04",
"commit": true,
"changes": [
"LABEL foo=bar"
]
}
]
}
$ packer build docker-label.json
docker output will be in this color.
==> docker: Creating a temporary directory for sharing data...
==> docker: Pulling Docker image: ubuntu:16.04
docker: 16.04: Pulling from library/ubuntu
docker: Digest:
sha256:58d0da8bc2f434983c6ca4713b08be00ff5586eb5cdff47bcde4b2e88fd40f88
docker: Status: Image is up to date for ubuntu:16.04
==> docker: Starting docker container...
docker: Run command: docker run -v
/Users/rickard.von.essen/.packer.d/tmp:/packer-files -d -i -t ubuntu:16.04
/bin/bash
docker: Container ID:
e231976dedf1f08ed8a7b8f85073c7f8d198d4b0ee9bcc6010df140e3b56b1a6
==> docker: Using docker communicator to connect: 172.17.0.2
==> docker: Committing the container
docker: Image ID:
sha256:f36adac65043d944f1e4f3d8764766f3238475d317785279f333838ce0e7889a
==> docker: Killing the container:
e231976dedf1f08ed8a7b8f85073c7f8d198d4b0ee9bcc6010df140e3b56b1a6
Build 'docker' finished.
==> Builds finished. The artifacts of successful builds are:
--> docker: Imported Docker image:
sha256:f36adac65043d944f1e4f3d8764766f3238475d317785279f333838ce0e7889a
$ docker inspect
sha256:f36adac65043d944f1e4f3d8764766f3238475d317785279f333838ce0e7889a
--format "{{ .Config.Labels }}"
map[foo:bar]
On Tue, Mar 19, 2019 at 4:57 PM 'Nicholas Bayle' via Packer <
[email protected]> wrote:
> I figured I was missing something like that.
>
> That said, I get:
>
>> docker inspect --format '{{ .ContainerConfig.Labels }}' 06a7e57ba554
>> map[]
>>
>
> Here's the full output. Labels is null:
>
>> docker inspect 06a7
>> [
>> {
>> "Id":
>> "sha256:06a7e57ba5549e6c2bd1bdbbd7ad6369bb471ee180b41e636cd2b60fc82f0f8f",
>> "RepoTags": [],
>> "RepoDigests": [],
>> "Parent": "",
>> "Comment": "Imported from -",
>> "Created": "2019-03-18T18:19:25.921251641Z",
>> "Container": "",
>> "ContainerConfig": {
>> "Hostname": "",
>> "Domainname": "",
>> "User": "",
>> "AttachStdin": false,
>> "AttachStdout": false,
>> "AttachStderr": false,
>> "Tty": false,
>> "OpenStdin": false,
>> "StdinOnce": false,
>> "Env": null,
>> "Cmd": null,
>> "Image": "",
>> "Volumes": null,
>> "WorkingDir": "",
>> "Entrypoint": null,
>> "OnBuild": null,
>> *"Labels": null*
>> },
>> "DockerVersion": "18.09.3",
>> "Author": "",
>> "Config": {
>> "Hostname": "",
>> "Domainname": "",
>> "User": "",
>> "AttachStdin": false,
>> "AttachStdout": false,
>> "AttachStderr": false,
>> "Tty": false,
>> "OpenStdin": false,
>> "StdinOnce": false,
>> "Env": null,
>> "Cmd": null,
>> "Image": "",
>> "Volumes": null,
>> "WorkingDir": "",
>> "Entrypoint": null,
>> "OnBuild": null,
>> *"Labels": null*
>> },
>> "Architecture": "amd64",
>> "Os": "linux",
>> "Size": 571834611,
>> "VirtualSize": 571834611,
>> "GraphDriver": {
>> "Data": {
>> "MergedDir":
>> "/var/lib/docker/overlay2/7a747e66900365c1a537cc8d11f9b226304211c22a13fea5be57a698cd5aea1a/merged",
>> "UpperDir":
>> "/var/lib/docker/overlay2/7a747e66900365c1a537cc8d11f9b226304211c22a13fea5be57a698cd5aea1a/diff",
>> "WorkDir":
>> "/var/lib/docker/overlay2/7a747e66900365c1a537cc8d11f9b226304211c22a13fea5be57a698cd5aea1a/work"
>> },
>> "Name": "overlay2"
>> },
>> "RootFS": {
>> "Type": "layers",
>> "Layers": [
>>
>> "sha256:ce86195a57b0d70635318da7f6123303ab8687b688cb458a55cd24be0fc8402d"
>> ]
>> },
>> "Metadata": {
>> "LastTagTime": "0001-01-01T00:00:00Z"
>> }
>> }
>> ]
>>
>
> On Tue, Mar 19, 2019 at 12:54 AM Rickard von Essen <
> [email protected]> wrote:
>
>> docker ps shows the running Docker *containers*
>>
>> You should use:
>> docker inspect <image> --format "{{ .ContainerConfig.Labels }}"
>>
>> Images labels doesn't propagate from a *image *to a *container* started
>> from it.
>>
>> On Mon, Mar 18, 2019 at 7:22 PM 'Nicholas Bayle' via Packer <
>> [email protected]> wrote:
>>
>>> I'm new to docker, so maybe this is just my ignorance, but does adding
>>> docker labels actually work with packer?
>>>
>>> 9 "builders": [{
>>>> 10 "type": "docker",
>>>> 11 "image": "ubuntu:18.04",
>>>> 12 "export_path": "output-docker/akm-{{user
>>>> `akm_version`}}-u{{user `u_version`}}-{{user `build_stamp`}}.tar",
>>>> 13 "changes": [
>>>> 14 "USER admin",
>>>> 15 "EXPOSE 6000 6001 6002 6003 5696",
>>>> 16 "LABEL com.townsend.version=1.0"
>>>> 17 ]
>>>> 18 }],
>>>>
>>>
>>> The resulting image has no labels.
>>>
>>> docker ps --format "table {{.ID}}\t{{.Labels}}"
>>>> CONTAINER ID LABELS
>>>> 11b32092d884
>>>>
>>>
>>> Nick
>>>
>>> --
>>> This mailing list is governed under the HashiCorp Community Guidelines -
>>> https://www.hashicorp.com/community-guidelines.html. Behavior in
>>> violation of those guidelines may result in your removal from this mailing
>>> list.
>>>
>>> GitHub Issues: https://github.com/mitchellh/packer/issues
>>> IRC: #packer-tool on Freenode
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Packer" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/packer-tool/CAGzi4%3D4w4um12GXPUbYiT%2BtUDMCkYBTNY%2B-VHpxMmoN%3D5QFjYQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/packer-tool/CAGzi4%3D4w4um12GXPUbYiT%2BtUDMCkYBTNY%2B-VHpxMmoN%3D5QFjYQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> This mailing list is governed under the HashiCorp Community Guidelines -
>> https://www.hashicorp.com/community-guidelines.html. Behavior in
>> violation of those guidelines may result in your removal from this mailing
>> list.
>>
>> GitHub Issues: https://github.com/mitchellh/packer/issues
>> IRC: #packer-tool on Freenode
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Packer" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/packer-tool/CALz9Rt9ybUaQ5V6A3Vto76kjB_%3DhXTGLNSq0SQA2rZTqG6hJdA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/packer-tool/CALz9Rt9ybUaQ5V6A3Vto76kjB_%3DhXTGLNSq0SQA2rZTqG6hJdA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/CAGzi4%3D6PUYHmOP%3DxLnsU2HB4CyNLk1FPUMO33vMedTNe6U7j%3Dg%40mail.gmail.com
> <https://groups.google.com/d/msgid/packer-tool/CAGzi4%3D6PUYHmOP%3DxLnsU2HB4CyNLk1FPUMO33vMedTNe6U7j%3Dg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/CALz9Rt8cyiqjP1HwkwpNQxVWCUwiJx%2BW76tW5v5WKN6%3DPVc32A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.