Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Extensible formula to manage Docker on MacOS, Windows, and GNU/Linux. Currently supports:

The default and states support:

The other states support container managmement.

Travis CI Build Status Semantic Release

A SaltStack formula for Docker on MacOS, GNU/Linux, Windows and Raspberry Pi (4b).

General notes

See the full SaltStack Formulas installation and usage instructions. If you are interested in writing or contributing to formulas, please pay attention to the Writing Formula Section. If you want to use this formula, please pay attention to the FORMULA file and/or git tag, which contains the currently released version. This formula is versioned according to Semantic Versioning. See Formula Versioning Section for more details.

Contributing to this repo

Commit message formatting is significant!!

Please see How to contribute for more details.

Available Meta states


Meta-state (This is a state that includes other states).

This state installs the Docker solution (see for Raspberry Pi support please see Notes


Meta-state (This is a state that includes other states).

Stop Docker daemon and remove docker packages ('docker', 'docker-engine', 'docker-ce', etc) on Linux. To protect OS integrity, this state won't remove packages listed as dependencies (i.e. python is kept).

Configures the upstream Docker's repo on RedHat/Debian OS.

This state removes upstream Docker package repository only, on RedHat/Debian OS.

This state installs Docker (see and

This state installs Dockerd daemon on Linux (systemd support).

This state stops Dockerd daemon on Linux (systemd support).

This state overrides default Docker options (i.e. /etc/default/docker):

        - DOCKER_OPTS="-s btrfs --dns"
        - export http_proxy=""

This state uninstalls Docker overrides (i.e. /etc/default/docker).

This state uninstalls Docker software.


Pulls and runs a number of docker containers. See docker container API for docker.containers options:

      - prometheus_simple
      - prometheus_detail

      image: "prom/prometheus:v1.7.1"

      image: "prom/prometheus:v1.7.1"
      # see


Saltstack dockercompose module state support (See

The intent is to provide an interface similar to the specification provided by docker-compose. The hope is that you may provide pillar data similar to that which you would use to define services with docker-compose. The assumption is that you are already using pillar data and salt formulae to represent the state of your existing infrastructure.

No real effort had been made to support every possible feature of docker-compose. Rather, we prefer the syntax provided by the docker-compose whenever it is reasonable for the sake of simplicity.

It is worth noting that we have added one attribute which is decidedly absent from the docker-compose specification. That attribute is dvc. This is a boolean attribute which allows us to define data only volume containers which can not be represented with the state since they are not intended to include a long living service inside the container.

See the included pillar.example for a representative pillar data block. To use this formula, you might target a host with the following pillar:

        dvc: true
        # image: &registry_image '' ## Fedora
        image: &registry_image 'registry:latest'
        container_name: &dvc 'registry-datastore'
        command: echo *dvc data volume container
          - &datapath '/registry'
        image: *registry_image
        container_name: 'registry-service'
          - *dvc
          SETTINGS_FLAVOR: 'local'
          STORAGE_PATH: *datapath
          SEARCH_BACKEND: 'sqlalchemy'
        # restart: 'always'    # compose v1.9
        deploy:                # compose v3
            condition: on-failure
            delay: 5s
            max_attempts: 3
            window: 120s
        # image: ''  ##Fedora
        image: 'nginx:latest'
        container_name: 'nginx-latest'
          - 'registry-service:registry'
          - '80:80'
          - '443:443'
          - /srv/docker-registry/nginx/:/etc/nginx/conf.d
          - /srv/docker-registry/auth/:/etc/nginx/conf.d/auth
          - /srv/docker-registry/certs/:/etc/nginx/conf.d/certs
        working_dir: '/var/www/html'
        volume_driver: 'local'
        userns_mode: 'host'

Then you would target a host with the following states:

  - base: docker
  - base:


Saltstack swarm module state support (See


Opposite of docker.swarm state (See


Create docker networks


Remove docker networks


Sub-states are available inside sub-directories.

Notes on Raspberry Pi support

There are some caveats with regard to the support of this module on Rasberry Pi 4b's.

  • This module has only been tested with Raspberry Pi 4b using Rasbian Os Version Buster
  • This module supports raspbian only when used from Salt 3002.6. Salt 3003.x fails with template isses.
  • Docker service is known to fail starting when freshly installed via this module on Rasbian Buster with all apt-get updates and upgrades performed. The error found in logs for failing to start is dockerd: failed to create NAT chain DOCKER

The Reason for this is as documented here . The following Fix followed by a restart fixes this. The summary reason is that the docker installer uses iptables for nat. Unfortunately Debian uses nftables. You can convert the entries over to nftables or just setup Debian to use the legacy iptables. On the target Raspberry Pi issue the following to resolve or incorporate the SLS before in your custom SLS

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
sudo shutdown -r 0  # Do a restart, Docker.d should then function

or the following SLS

    - path:  /usr/sbin/iptables-legacy
    - path:  /usr/sbin/ip6tables-legacy

The provisioning of docker to raspbian uses functionality from It specifically mentions Using these scripts is not recommended for production environments, and you should understand the potential risks before you use them: The reasons are stated as :

  • The scripts require root or sudo privileges to run. Therefore, you should carefully examine and audit the scripts before running them.
  • The scripts attempt to detect your Linux distribution and version and configure your package management system for you. In addition, the scripts do not allow you to customize any installation parameters. This may lead to an unsupported configuration, either from Docker’s point of view or from your own organization’s guidelines and standards.
  • The scripts install all dependencies and recommendations of the package manager without asking for confirmation. This may install a large number of packages, depending on the current configuration of your host machine.
  • The script does not provide options to specify which version of Docker to install, and installs the latest version that is released in the “edge” channel.
  • Do not use the convenience script if Docker has already been installed on the host machine using another mechanism.


Linux testing is done with kitchen-salt.


  • Ruby
  • Docker
$ gem install bundler
$ bundle install
$ bin/kitchen test [platform]

Where [platform] is the platform name defined in kitchen.yml, e.g. debian-9-2019-2-py3.

bin/kitchen converge

Creates the Docker instance and runs the docker main state, ready for testing.

bin/kitchen verify

Runs the inspec tests on the actual instance.

bin/kitchen destroy

Removes the Docker instance.

bin/kitchen test

Runs all of the stages above in one go: i.e. destroy + converge + verify + destroy.

bin/kitchen login

Gives you SSH access to the instance for manual testing.