Hello

Its always better to have packer clean, and you can use a shell script to
wrap pre-requirements

as packer usually check state before running, may/may not work in the way
you want.

There is a provisioner named shell-local you can use to run commands in the
host but its too late to import a docker image there.



if I try to docker pull an image, please notice it does happen after the
docker has been "started"


# packer build template.json

*xenial output will be in this color.*


*==> xenial: Creating a temporary directory for sharing data...*

*==> xenial: Starting docker container...*

    xenial: Run command: docker run -v
/root/.packer.d/tmp/packer-docker750999803:/packer-files -d -i -t
ubuntu:xenial /bin/bash

    xenial: Container ID:
aad89910ad6ec68fc2ea2b89055476c1f406df00205548e7b5d3e3a205aeb630

*==> xenial: Executing local command: docker pull ubuntu:xenial*

    xenial: xenial: Pulling from library/ubuntu

    xenial: Digest:
sha256:e348fbbea0e0a0e73ab0370de151e7800684445c509d46195aef73e090a49bd6

    xenial: Status: Image is up to date for ubuntu:xenial

*==> xenial: Committing the container*

    xenial: Image ID:
sha256:27053b3a833a390853da0a22266f3c75bcbe10422e4f3637963fad2def3f9072

*==> xenial: Killing the container:
aad89910ad6ec68fc2ea2b89055476c1f406df00205548e7b5d3e3a205aeb630*

*==> xenial: Running post-processor: docker-tag*

    xenial (docker-tag): Tagging image:
sha256:27053b3a833a390853da0a22266f3c75bcbe10422e4f3637963fad2def3f9072

    xenial (docker-tag): Repository: xenial:latest

*Build 'xenial' finished.*


==> Builds finished. The artifacts of successful builds are:

--> xenial: Imported Docker image:
sha256:27053b3a833a390853da0a22266f3c75bcbe10422e4f3637963fad2def3f9072

--> xenial: Imported Docker image: xenial:latest

root@ubuntu-1604-vmware:/vagrant/import# cat template.json

{

    "variables": {

    },

    "builders": [

        {

            "commit": true,

            "image": "ubuntu:xenial",

            "pull": false,

            "type": "docker",

            "name": "xenial"

        }

    ],

    "post-processors": [

        {

            "repository": "xenial",

            "tag": "latest",

            "type": "docker-tag"

        }

    ],

    "provisioners": [

        {

            "command": "docker pull ubuntu:xenial",

            "type": "shell-local"

        }

    ]

}

root@ubuntu-1604-vmware:/vagrant/import#


So you are better having a shell script that does the import and then runs
packer.


Alvaro.




On Fri, Apr 6, 2018 at 12:14 PM, Saurabh <saurabh240...@gmail.com> wrote:

> Hi All,
>
> How I can use packer for  docker load --input tomcat.tar command ?
>
> Any Solutions for this ?
>
> Regards
> Saurabh
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/3827717b-7130-4031-b2d0-31e34c1edde8%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/3827717b-7130-4031-b2d0-31e34c1edde8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Alvaro

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

Reply via email to