docker-index.sls 1 2 3 4 5 6 7 docker_index_stop_if_old : cmd.run : - name : docker stop docker_index - unless : docker inspect --format "{{.Image }}" docker_index | grep $(docker images | grep "index.docker.io/ekristen/docker-index:dev" | awk '{ print $3 }') - require : - docker : docker_index_image - order : 111 The unless basically looks at the list of available images and grabs the unique hash of index.docker.io/ekristen/docker-index:dev and then greps the.Image value from the inspect command of the current running container named docker-index.
docker-index.sls 1 2 3 4 5 6 7 8 9 10 11 12 13 docker_index_container : docker.installed : - name : docker_index - image : index.docker.io/ekristen/docker-index:dev - environment : - "REDIS_HOST" : "192.168.1.100" - "REDIS_PORT