docker-save with tags

57 views
Skip to first unread message

Nicholas Bayle

unread,
Apr 29, 2019, 5:46:37 PM4/29/19
to packe...@googlegroups.com
Hello, when using docker save in general, you can specify tags. See:

However, with the docker-save post-processor, there doesn't appear to be a way to tag the exported image.

I looked at the docker-tag post-processor, but this leaves the image in the repo, not exported to tar.

Is there a way to accomplish this, or can this be a feature request?

Nick

Rickard von Essen

unread,
Apr 30, 2019, 3:58:25 AM4/30/19
to packe...@googlegroups.com
You should do this with the docker-tag post-processor and ensure the it is in a sequence after docker-tag. 

--
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 packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAGzi4%3D6VcTV9xX%3Drmkpzh5yVLpTu4fXjo5ArdUUH9wut04md9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Nicholas Bayle

unread,
Apr 30, 2019, 11:31:13 AM4/30/19
to packe...@googlegroups.com
Indeed it is after docker-tag and the tags are empty when imported with: docker load -i blah.tar

Rickard von Essen

unread,
May 1, 2019, 4:10:59 AM5/1/19
to packe...@googlegroups.com
Does it work as you expect if you do it manually with the docker cli? 

Nicholas Bayle

unread,
May 1, 2019, 1:42:09 PM5/1/19
to packe...@googlegroups.com
Yes:

2019/05/01 10:34:30 /usr/local/bin/packer: plugin process exited

nicholas@pickle:~/dev/chef-akm (master)$ docker image ls
REPOSITORY          TAG                         IMAGE ID            CREATED             SIZE
townsend/akm        4.6.1-u18.04-201905011031   34ee2413333d        2 minutes ago       602MB
ubuntu              18.04                       d131e0fa2585        4 days ago          102MB

nicholas@pickle:~/dev/chef-akm (master)$ docker save -o pickles.tar 34 townsend/akm

nicholas@pickle:~/dev/chef-akm (master)$ docker image rm 34
Untagged: townsend/akm:4.6.1-u18.04-201905011031
Deleted: sha256:34ee2413333d8269c9425fdf41136b046d2851b29e1b454c7f2b851bd516097a
Deleted: sha256:e61945fdf42b6ab49cef82486054eec7a280152a4fec5a0afca48913e63e68e7

nicholas@pickle:~/dev/chef-akm (master)$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              18.04               d131e0fa2585        4 days ago          102MB

nicholas@pickle:~/dev/chef-akm (master)$ docker load -i pickles.tar
650c8878d56d: Loading layer  511.4MB/511.4MB
Loaded image: townsend/akm:4.6.1-u18.04-201905011031

nicholas@pickle:~/dev/chef-akm (master)$ docker image ls
REPOSITORY          TAG                         IMAGE ID            CREATED             SIZE
townsend/akm        4.6.1-u18.04-201905011031   34ee2413333d        3 minutes ago       602MB
ubuntu              18.04                       d131e0fa2585        4 days ago          102MB


Thank you,
Nick

Nicholas Bayle

unread,
May 6, 2019, 11:30:13 AM5/6/19
to packe...@googlegroups.com
Should I open a feature request, or is there more to try?

Thank you,
Nick

Rickard von Essen

unread,
May 6, 2019, 11:35:37 AM5/6/19
to packe...@googlegroups.com
Can you show the packer template you used first?

Nicholas Bayle

unread,
May 6, 2019, 11:41:35 AM5/6/19
to packe...@googlegroups.com
Sure.

{
  "variables": {
    "home": "{{env `HOME`}}",
    "build_stamp": "{{env `DATE_STAMP`}}",
    "packer_stamp": "{{env `PACKER_DATE_STAMP`}}",
    "akm_version": "4.6.1",
    "u_version": "18.04"
  },
  "builders": [
    {
      "type": "docker",
      "image": "ubuntu:18.04",
      "commit": true,
      "changes": [
        "USER admin",
        "EXPOSE 22 6000 6001 6002 6003 5696",
        "LABEL com.townsend.name=akm",
        "LABEL com.townsend.build-date={{user `packer_stamp`}}",
        "LABEL com.townsend.vendor='Hooray'",
        "LABEL com.townsend.description='Blah'",
        "LABEL com.townsend.url='https://google.com'",
        "LABEL com.townsend.schema-version=1.0",
        "LABEL com.townsend.version={{user `akm_version`}}-u{{user `u_version`}}-{{user `build_stamp`}}"
      ]
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline": ["apt-get update; apt-get --yes install sudo curl wget"]
    },
    {
      "type": "chef-solo",
      "cookbook_paths": ["cookbooks"],
      "run_list": ["akm::docker"]
    },
    {
      "type": "shell",
      "inline": ["echo 'vagrant' | sudo apt-get --yes --purge autoremove chef"]
    },
    {
      "type": "shell",
      "inline": ["dpkg-query -f '${Package} ${Version}\n' -W > /tmp/manifest; sleep 2"]
    },
    {
      "type": "file",
      "source": "/tmp/manifest",
      "destination": "manifest",
      "direction": "download"
    },
    {
      "type": "shell",
      "inline": ["rm /tmp/manifest"]
    }
  ],
  "post-processors": [
    {
      "type": "shell-local",
      "inline": ["mv manifest manifests/manifest-akm-{{user `akm_version`}}-u{{user `u_version`}}-{{user `build_stamp`}}-docker.txt"]
    },
    {
      "type": "docker-tag",
      "repository": "townsend/akm",
      "tag": "{{user `akm_version`}}-u{{user `u_version`}}-{{user `build_stamp`}}"
    },
    {
      "type": "docker-save",
      "path": "output-docker/akm-{{user `akm_version`}}-u{{user `u_version`}}-{{user `build_stamp`}}.tar"
    }
  ]
}




Rickard von Essen

unread,
May 6, 2019, 11:53:33 AM5/6/19
to packe...@googlegroups.com

"post-processors": [
    {
      "type": "shell-local",
      "inline": ["mv manifest manifests/manifest-akm-{{user `akm_version`}}-u{{user `u_version`}}-{{user `build_stamp`}}-docker.txt"]
    },
    [
      {
        "type": "docker-tag",
        "repository": "townsend/akm",
        "tag": "{{user `akm_version`}}-u{{user `u_version`}}-{{user `build_stamp`}}"
      },
      {
        "type": "docker-save",
        "path": "output-docker/akm-{{user `akm_version`}}-u{{user `u_version`}}-{{user `build_stamp`}}.tar"
      }
    ]
  ]

Nicholas Bayle

unread,
May 6, 2019, 12:31:08 PM5/6/19
to packe...@googlegroups.com
Ha, I see. Didn't know sequence had a special meaning.

That works very well, thanks.


Reply all
Reply to author
Forward
0 new messages