salt: Grains/pillar not updated for docker_image

Description of Issue

When running salt.state.docker_image.present the container being built has the host’s pillar and grains instead of the container’s. This is mostly an issue for detecting if the state is being run in a container via grains.virtual_subtype.

Setup

{% if grains.virtual_subtype is defined and grains.virtual_subtype == "Docker" %}
it-works-as-expected:
  test.succeed_without_changes:
    - name: "Running inside of a docker container"
{% else %}
it-doesnt-work:
  test.fail_without_changes:
    - name: "Detected as not running inside of docker even though it is"
{% endif %}

Steps to Reproduce Issue

docker-doesnt-work-as-expected:
  docker_image.present:
    - name: pleasefix
    - tag: lovesalt
    - sls: theabovestate
    - base: fedora

Versions Report

Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: 1.11.5
       cherrypy: Not Installed
       dateutil: 2.8.0
      docker-py: 3.5.0
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.30.1
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.1
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.16 (default, Apr 30 2019, 15:54:43)
   python-gnupg: Not Installed
         PyYAML: 5.1
          PyZMQ: 17.0.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 5.0.2
            ZMQ: 4.3.1
 
System Versions:
           dist: fedora 30 Thirty
         locale: UTF-8
        machine: x86_64
        release: 5.0.17-300.fc30.x86_64
         system: Linux
        version: Fedora 30 Thirty

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

Wow! Yes, that works swimmingly! So nice to have this working. Thank you Wayne.