Hi,

I have an easy reproducable example for you:

$ cat simple.json 
{
    "builders": [{
        "type": "docker",
        "image": "centos:7",
        "export_path": "image.tar"
    }]
}

The command *packer build demo.json* (as usual).

Now a small and simple Python setup:


   1. Install tox with *pip install tox*. If you have Centos you can say: 
   sudo yum -y install python-setuptools;sudo easy_install pip; sudo pip 
   install tox
   On Debian it's also easy: *sudo apt-get install python pip;sudo pip 
   install tox*.
   2. Now organize two have a setup.py (choose a folder demo or so).
   $ cat setup.py 
   from setuptools import setup
   
   setup(name='demo',
         version='1.0',
         description='demo',
         long_description='demo',
         author='Thomas Lehmann',
         author_email='[email protected]',
         license="MIT",
         install_requires=[],
         packages=[],
         url="https://github.com/Nachtfeuer/pipeline";,
         classifiers=[
             "Development Status :: 5 - Production/Stable",
             "Intended Audience :: Developers",
             "License :: OSI Approved :: MIT License",
             "Operating System :: Unix"
         ])
   
   
   3. Now provide a *tox.ini* file in same folder
   $ cat tox.ini 
   [testenv]
   commands = \
       packer build {toxinidir}/simple.json
   4. Now just say "tox" and press enter:
   
   $ tox
   GLOB sdist-make: /tmp/demo/setup.py
   python inst-nodeps: /tmp/demo/.tox/dist/demo-1.0.zip
   python installed: demo==1.0
   python runtests: PYTHONHASHSEED='3442765722'
   python runtests: commands[0] | packer build /tmp/demo/simple.json
   WARNING:test command found but not installed in testenv
     cmd: /usr/local/bin/packer
     env: /tmp/demo/.tox/python
   Maybe you forgot to specify a dependency? See also the 
   whitelist_externals envconfig setting.
   docker output will be in this color.
   
   ==> docker: Creating a temporary directory for sharing data...
   ==> docker: Pulling Docker image: centos:7
       docker: 7: Pulling from library/centos
       docker: Digest: sha256:
   dcbc4e5e7052ea2306eed59563da1fec09196f2ecacbe042acbdcd2b44b05270
       docker: Status: Image is up to date for centos:7
   ==> docker: Starting docker container...
       docker: Run command: docker run -v ~/.packer.d/tmp/packer-
   docker717100724:/packer-files -d -i -t centos:7 /bin/bash
   ==> docker: Error running container: Docker exited with a non-zero exit 
   status.
   ==> docker: Stderr: docker: Error response from daemon: create ~
   /.packer.d/tmp/packer-docker717100724: 
   "~/.packer.d/tmp/packer-docker717100724" includes invalid characters for 
   a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If 
   you intended to pass a host directory, use absolute path.
   ==> docker: See 'docker run --help'.
   ==> docker:
   Build 'docker' errored: Error running container: Docker exited with a non
   -zero exit status.
   Stderr: docker: Error response from daemon: create ~/.packer.d/tmp/packer
   -docker717100724: "~/.packer.d/tmp/packer-docker717100724" includes 
   invalid characters for a local volume name, only 
   "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host 
   directory, use absolute path.
   See 'docker run --help'.
   
   
   ==> Some builds didn't complete successfully and had errors:
   --> docker: Error running container: Docker exited with a non-zero exit 
   status.
   Stderr: docker: Error response from daemon: create 
   ~/.packer.d/tmp/packer-docker717100724: 
   "~/.packer.d/tmp/packer-docker717100724" includes invalid characters for a 
   local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you 
   intended to pass a host directory, use absolute path.
   See 'docker run --help'.
   
   
   ==> Builds finished but no artifacts were created.
   ERROR: InvocationError: '/usr/local/bin/packer build /tmp/demo/simple.
   json'
   ___________________________________________________ summary 
   ____________________________________________________
   ERROR:   python: commands failed
   
   
   
I hope it helps,

regards,
Thomas


Am Samstag, 17. März 2018 15:01:34 UTC+1 schrieb 
[email protected]:
>
> Hi,
>
> I'm author of the tool spline: https://github.com/Nachtfeuer/pipeline
> I'm working on extending spline for a packer task like following:
>
> $ cat examples/packer.yaml
> model:
>     image: centos:7
>
> pipeline:
>     - stage(Example):
>         - tasks(ordered):
>             - packer:
>                 script: |
>                   {
>                     "builders": [{
>                         "type": "docker",
>                         "image": "{{ model.image }}",
>                         "commit": true,
>                         "changes": [
>                             "LABEL pipeline={{ env.PIPELINE_PID }}",
>                             "LABEL pipeline-stage={{ env.PIPELINE_STAGE 
> }}"
>                         ]
>                     }],
>
>                     "provisioners": [{
>                         "type": "shell",
>                         "inline": [
>                             "yum -y install python-setuptools",
>                             "easy_install pip",
>                             "pip install tox"
>                         ]
>                     }],
>
>                     "post-processors": [{
>                         "type": "docker-tag",
>                         "repository": "spline/packer/demo",
>                         "tag": "0.1"
>                     }]
>                   }
>
>
> This works fine. However ... when coming to unit/regression tests I 
> detected following issue:
>
> Running via tox (wrapper for Python virtual environment) the unittest for 
> the Packer task the Packer build complains about this:
>     *~/.packer.d/tmp/packer-docker735583400" includes invalid characters 
> for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed*
>
> I also can run the one test without tox and no problem arrives: 
>    * PYTHONPATH=$PWD python -m unittest discover -v -s tests -p 
> "test_packer.py"*
>
> The Packer build command is following:
> *packer build -parallel=true -on-error=cleanup /tmp/packer-USh6y4.json*
>
> Is it possible to tell packer to use another root path like current folder 
> or /tmp without special characters?
> (ot at least it should be ensured that the full path is used)
>
> I'm uisng Packer 1.2.1 and Docker 17.12.1-ce
>
> Regards,
> Thomas
>
> My question now: what can I d
>
>
>

-- 
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/c06712fe-a5a5-4efe-b99a-7509e8a8e5af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to