Extensible formula to manage Docker on MacOS, Windows, and GNU/Linux. Currently supports:
- software Docker (https://docs.docker.com/engine/install) [all OS]
- containers Manage Containers. [all OS]
- compose Compose Containers. [all OS]
- swarm Docker Swarm. [Linux]
The default docker.software and docker.compose.software states support:
- archive Docker-Engine (https://docs.docker.com/engine/install) [Linux]
- desktop Docker-Desktop (https://docs.docker.com/desktop) [Windows, MacOS]
- Docker-Compose (https://docs.docker.com/compose/install/) [Linux]
The other states support container managmement.
A SaltStack formula for Docker on MacOS, GNU/Linux and Windows.
Table of Contents
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.
Commit message formatting is significant!!
Please see :ref:`How to contribute <CONTRIBUTING>` for more details.
docker
docker.clean
docker.software.package.repo
docker.software.package.repo.clean
docker.software
docker.software.service
docker.software.service
docker.software.config
docker.software.config.clean
docker.software.clean
docker.containers
docker.compose
docker.compose.ng
docker.swarm
docker.swarm.clean
docker.networks
docker.networks.clean
Meta-state (This is a state that includes other states).
This state installs the Docker solution (see https://docs.docker.io)
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 https://docs.docker.com/engine/install and https://docs.docker.com/desktop/)
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: pkg: docker: config: - DOCKER_OPTS="-s btrfs --dns 8.8.8.8" - export http_proxy="http://172.17.42.1:3128"
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:
docker: containers: running: - prometheus_simple - prometheus_detail prometheus_simple: image: "prom/prometheus:v1.7.1" prometheus_detail: image: "prom/prometheus:v1.7.1" # see https://docker-py.readthedocs.io/en/stable/containers.html
Saltstack dockercompose module state support (See https://docs.saltstack.com/en/2018.3/ref/modules/all/salt.modules.dockercompose.html).
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 docker.software.service.running
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:
docker:
compose:
ng:
registry-datastore:
dvc: true
# image: ®istry_image 'docker.io/registry:latest' ## Fedora
image: ®istry_image 'registry:latest'
container_name: &dvc 'registry-datastore'
command: echo *dvc data volume container
volumes:
- &datapath '/registry'
registry-service:
image: *registry_image
container_name: 'registry-service'
volumes_from:
- *dvc
environment:
SETTINGS_FLAVOR: 'local'
STORAGE_PATH: *datapath
SEARCH_BACKEND: 'sqlalchemy'
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: '/registry'
ports:
- 127.0.0.1:5000:5000
# restart: 'always' # compose v1.9
deploy: # compose v3
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
nginx-latest:
# image: 'docker.io/nginx:latest' ##Fedora
image: 'nginx:latest'
container_name: 'nginx-latest'
links:
- 'registry-service:registry'
ports:
- '80:80'
- '443:443'
volumes:
- /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:
include:
- base: docker
- base: docker.compose.ng
Saltstack swarm module state support (See https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.swarm.html).
Opposite of docker.swarm state (See https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.swarm.html).
Create docker networks
Remove docker networks
Sub-states are available inside sub-directories.
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
.
Creates the Docker instance and runs the docker
main state, ready for testing.
Runs the inspec
tests on the actual instance.
Removes the Docker instance.
Runs all of the stages above in one go: i.e. destroy
+ converge
+ verify
+ destroy
.
Gives you SSH access to the instance for manual testing.