blob: ef6b711e8fbd79a850e8631ca7727400604cdf2f [file] [log] [blame]
Michael Kutý17649402016-03-19 23:57:43 +01001
Aleš Komárek028b8852017-04-11 13:10:58 +02002==============
3Docker Formula
4==============
Michael Kutý17649402016-03-19 23:57:43 +01005
6Docker is a platform for developers and sysadmins to develop, ship, and run applications. Docker lets you quickly assemble applications from components and eliminates the friction that can come when shipping code. Docker lets you get your code tested and deployed into production as fast as possible.
7
8Docker is supported on the following systems:
9
10* Debian 8.0 Jessie (64-bit)
11* Ubuntu Trusty 14.04 (LTS) (64-bit)
12* Ubuntu Precise 12.04 (LTS) (64-bit)
13* Ubuntu Raring 13.04 and Saucy 13.10 (64 bit)
14
Aleš Komárek028b8852017-04-11 13:10:58 +020015Sample Pillars
16==============
Michael Kutý17649402016-03-19 23:57:43 +010017
Aleš Komárek028b8852017-04-11 13:10:58 +020018Docker Host
19-----------
Filip Pytloune27a90d2016-08-29 14:08:34 +020020
Michael Kutý17649402016-03-19 23:57:43 +010021.. code-block:: yaml
22
23 docker:
24 host:
25 enabled: true
Tomáš Kukrál55cbec72017-06-19 17:21:04 +020026 options:
27 bip: 172.31.255.1/16
28 insecure_registries:
29 - 127.0.0.1
30 - 10.0.0.1
31 log-driver: json-file
32 log-opts:
33 max-size: 50m
Michael Kutý17649402016-03-19 23:57:43 +010034
Aleš Komárek028b8852017-04-11 13:10:58 +020035
36Docker Swarm
37------------
Filip Pytloun2720a0d2016-11-02 14:15:55 +010038
39Role can be master, manager or worker. Where master is the first manager that
40will initialize the swarm.
41
42Metadata for manager (first node):
43
44.. code-block:: yaml
45
46 docker:
47 host:
48 enabled: true
49 swarm:
50 role: manager
51 advertise_addr: 192.168.1.5
52 bind:
53 address: 192.168.1.5
54 port: 2377
55
Aleš Komárek028b8852017-04-11 13:10:58 +020056Metadata for worker.
Filip Pytloun2720a0d2016-11-02 14:15:55 +010057
58.. code-block:: yaml
59
60 docker:
61 host:
62 enabled: true
63 swarm:
64 role: worker
65 master:
66 host: 192.168.1.5
67 port: 2377
68
69Token to join to master node is obtained from grains using salt.mine. In case
70of any ``join_token undefined`` issues, ensure you have ``docker_swarm_``
71grains available.
72
Aleš Komárek028b8852017-04-11 13:10:58 +020073Docker Client
74-------------
Michael Kutý17649402016-03-19 23:57:43 +010075
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020076Container
77~~~~~~~~~
78
79.. code-block:: yaml
80
Michael Kutý17649402016-03-19 23:57:43 +010081 docker:
Filip Pytloune27a90d2016-08-29 14:08:34 +020082 client:
Michael Kutý17649402016-03-19 23:57:43 +010083 container:
Filip Pytloun87169542016-08-29 13:38:30 +020084 jenkins:
85 # Don't start automatically
86 start: false
87 restart: unless-stopped
88 image: jenkins:2.7.1
Michael Kutý17649402016-03-19 23:57:43 +010089 ports:
Filip Pytloun87169542016-08-29 13:38:30 +020090 - 8081:8080
91 - 50000:50000
92 environment:
93 JAVA_OPTS: "-Dhudson.footerURL=https://www.example.com"
94 volumes:
95 - /srv/volumes/jenkins:/var/jenkins_home
Michael Kutý17649402016-03-19 23:57:43 +010096
Aleš Komárek028b8852017-04-11 13:10:58 +020097Using Docker Compose
98~~~~~~~~~~~~~~~~~~~~
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020099
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200100There are two states that provides this functionality:
101
102- docker.client.stack
103- docker.client.compose
104
105Stack is new and works with Docker Swarm Mode. Compose is legacy and works
106only if node isn't member of Swarm.
107Metadata for both states are similar and differs only in implementation.
108
109Stack
110^^^^^
111
112.. code-block:: yaml
113
114 docker:
115 client:
116 stack:
117 django_web:
118 enabled: true
119 update: true
120 environment:
121 SOMEVAR: somevalue
Simon Pasquier48482c22017-08-10 15:14:17 +0200122 version: "3.1"
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200123 service:
124 db:
125 image: postgres
126 web:
127 image: djangoapp
128 volumes:
129 - /srv/volumes/django:/srv/django
130 ports:
131 - 8000:8000
132 depends_on:
133 - db
134
135Compose
136^^^^^^^
137
Filip Pytloun21d9af92016-08-30 08:13:39 +0200138There are three options how to install docker-compose:
139
140- distribution package (default)
141- using Pip
142- using Docker container
143
144Install docker-compose using Docker (default is distribution package)
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200145
146.. code-block:: yaml
147
148 docker:
149 client:
150 compose:
Filip Pytloun21d9af92016-08-30 08:13:39 +0200151 source:
152 engine: docker
153 image: docker/compose:1.8.0
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200154 django_web:
155 # Run up action, any positional argument to docker-compose CLI
156 # If not defined, only docker-compose.yml is generated
157 status: up
Filip Pytlounbe2b4a82016-09-15 18:10:24 +0200158 # Run image pull every time state is run triggering container
159 # restart in case it's changed
160 pull: true
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200161 environment:
162 SOMEVAR: somevalue
163 service:
164 db:
165 image: postgres
166 web:
167 image: djangoapp
168 volumes:
169 - /srv/volumes/django:/srv/django
170 ports:
171 - 8000:8000
172 depends_on:
173 - db
174
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200175Service
176-------
177
Filip Pytlounab52ede2016-11-02 16:59:49 +0100178To deploy service in Swarm mode, you can use ``docker.client.service``:
179
180.. code-block:: yaml
181
182 parameters:
183 docker:
184 client:
185 service:
186 postgresql:
187 environment:
188 POSTGRES_USER: user
189 POSTGRES_PASSWORD: password
190 POSTGRES_DB: mydb
191 restart:
192 condition: on-failure
193 image: "postgres:9.5"
194 ports:
195 - 5432:5432
196 volume:
197 data:
198 type: bind
199 source: /srv/volumes/postgresql/maas
200 destination: /var/lib/postgresql/data
201
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200202
Aleš Komárek028b8852017-04-11 13:10:58 +0200203Docker Registry
204---------------
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200205
206.. code-block:: yaml
207
208 docker:
209 registry:
210 log:
211 level: debug
212 formatter: json
213 cache:
214 engine: redis
215 host: localhost
216 storage:
217 engine: filesystem
218 root: /srv/docker/registry
219 bind:
220 host: 0.0.0.0
221 port: 5000
222 hook:
223 mail:
224 levels:
225 - panic
226 # Options are rendered as yaml as is so use hook-specific options here
227 options:
228 smtp:
229 addr: smtp.sendhost.com:25
230 username: sendername
231 password: password
232 insecure: true
233 from: name@sendhost.com
234 to:
235 - name@receivehost.com
236
marco85b72a62016-07-07 13:08:33 +0200237Docker login to private registry
marco85b72a62016-07-07 13:08:33 +0200238
239.. code-block:: yaml
240
241 docker:
242 host:
243 enabled: true
244 registry:
245 first:
246 address: private.docker.com
247 user: username
248 password: password
249 second:
250 address: private2.docker.com
251 user: username2
252 password: password2
Michael Kutý17649402016-03-19 23:57:43 +0100253
Aleš Komárek028b8852017-04-11 13:10:58 +0200254
255More Information
256================
Michael Kutý17649402016-03-19 23:57:43 +0100257
258* https://docs.docker.com/installation/ubuntulinux/
259* https://github.com/saltstack-formulas/docker-formula
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200260
Filip Pytlound617a762017-02-02 13:02:03 +0100261
262Documentation and Bugs
263======================
264
265To learn how to install and update salt-formulas, consult the documentation
266available online at:
267
268 http://salt-formulas.readthedocs.io/
269
270In the unfortunate event that bugs are discovered, they should be reported to
271the appropriate issue tracker. Use Github issue tracker for specific salt
272formula:
273
274 https://github.com/salt-formulas/salt-formula-docker/issues
275
276For feature requests, bug reports or blueprints affecting entire ecosystem,
277use Launchpad salt-formulas project:
278
279 https://launchpad.net/salt-formulas
280
281You can also join salt-formulas-users team and subscribe to mailing list:
282
283 https://launchpad.net/~salt-formulas-users
284
285Developers wishing to work on the salt-formulas projects should always base
286their work on master branch and submit pull request against specific formula.
287
288 https://github.com/salt-formulas/salt-formula-docker
289
290Any questions or feedback is always welcome so feel free to join our IRC
291channel:
292
293 #salt-formulas @ irc.freenode.net