1 Run this [Salt Stack][salt] minion image with:
3 $ docker run -d --name salt-minion-0 --hostname salt-minion-0 wking/salt-minion
5 The [default master name][master-name] is `salt`, so make sure that
6 resolves appropriately on your Docker host (via DNS or an entry in
12 You have two options for setting up minon keys. The more secure
13 approach is to create and install minion keys on the master:
15 salt# mkdir /tmp/salt-minion-0
16 salt# chmod 700 /tmp/salt-minion-0
17 salt# salt-key --gen-keys=minion --gen-keys-dir=/tmp/salt-minion-0
18 salt# cp /tmp/salt-minion-0/minion.pub /etc/salt/pki/master/minions/salt-minion-0
19 salt# cp /etc/salt/pki/master/master.pub /tmp/salt-minion-0/minion_master.pub
20 salt# scp -rp /tmp/salt-minion-0/ docker-host:/etc/salt/pki/salt-minion-0/
21 salt# rm -rf /tmp/salt-minion-0
23 and [preseed the minion][preseed] with a [volume
26 $ docker run -d --name salt-minion-0 --hostname salt-minion-0 \
27 > -v /etc/salt/pki/salt-minion-0:/etc/salt/pki/minion wking/salt-minion
29 The less secure approach is to [auto-accept][] the minion's
30 internally-generated key.
35 If you blow away a minion container and replace it with a
36 freshly-spawned container, you may get errors in the minion logs like:
38 Feb 25 20:14:18 salt-minion-0 2014-02-25 20:14:18,257 [salt.fileclient ][INFO ] Fetching file ** done ** 'elasticsearch/init.sls'
39 Feb 25 20:14:18 salt-minion-0 2014-02-25 20:14:18,289 [salt.state ][INFO ] Executing state file.managed for /etc/portage/package.use/elasticsearch
40 Feb 25 20:14:18 salt-minion-0 2014-02-25 20:14:18,396 [salt.fileclient ][INFO ] Fetching file ** done ** 'elasticsearch/files/gentoo/package.use'
41 Feb 25 20:14:18 salt-minion-0 2014-02-25 20:14:18,402 [salt.state ][ERROR ] An exception occurred in this state: Traceback (most recent call last):
42 File "/usr/lib64/python2.7/site-packages/salt/state.py", line 1305, in call
43 *cdata['args'], **cdata['kwargs'])
44 File "/usr/lib64/python2.7/site-packages/salt/states/file.py", line 1157, in managed
46 File "/usr/lib64/python2.7/site-packages/salt/modules/file.py", line 2150, in manage_file
48 File "/usr/lib64/python2.7/site-packages/salt/utils/__init__.py", line 599, in copyfile
49 '[Errno 2] No such file or directory: {0}'.format(source)
50 IOError: [Errno 2] No such file or directory: /var/cache/salt/minion/files/base/elasticsearch/files/gentoo/package.use
52 That's because the master expects the salt state to be cached on the
53 old container. To fill in the cache on the new container, you'll want
54 to [manually sync][sync_all] the minion:
56 salt# salt salt-minion-0 saltutil.sync_all
58 [salt]: http://saltstack.com/community/
59 [master-name]: http://docs.saltstack.com/en/latest/ref/configuration/minion.html#master
60 [preseed]: http://docs.saltstack.com/en/latest/topics/tutorials/preseed_key.html
61 [volume-mount]: http://docs.docker.com/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume
62 [auto-accept]: http://docs.saltstack.com/en/latest/ref/configuration/master.html#auto-accept
63 [sync_all]: http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.saltutil.html#salt.modules.saltutil.sync_all