blob: ff95bc19c13e28e11b2649707a025cd90564bed4 [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
Aleš Komárek028b8852017-04-11 13:10:58 +02008Sample Pillars
9==============
Michael Kutý17649402016-03-19 23:57:43 +010010
Aleš Komárek028b8852017-04-11 13:10:58 +020011Docker Host
12-----------
Filip Pytloune27a90d2016-08-29 14:08:34 +020013
Michael Kutý17649402016-03-19 23:57:43 +010014.. code-block:: yaml
15
16 docker:
17 host:
18 enabled: true
Tomáš Kukrál55cbec72017-06-19 17:21:04 +020019 options:
20 bip: 172.31.255.1/16
Tomáš Kukrálb2debce2017-09-22 08:17:39 +020021 insecure-registries:
Tomáš Kukrál55cbec72017-06-19 17:21:04 +020022 - 127.0.0.1
23 - 10.0.0.1
24 log-driver: json-file
25 log-opts:
26 max-size: 50m
Michael Kutý17649402016-03-19 23:57:43 +010027
Aleš Komárek028b8852017-04-11 13:10:58 +020028
Tomáš Kukrál19a39602017-08-27 22:21:47 +020029Configure proxy for docker host
30
31.. code-block:: yaml
32
33 docker:
34 host:
35 proxy:
36 enabled: true
37 http: http://user:pass@proxy:3128
38 https: http://user:pass@proxy:3128
39 no_proxy:
40 - localhost
41 - 127.0.0.1
42 - docker-registry
43
44
Aleš Komárek028b8852017-04-11 13:10:58 +020045Docker Swarm
46------------
Filip Pytloun2720a0d2016-11-02 14:15:55 +010047
48Role can be master, manager or worker. Where master is the first manager that
49will initialize the swarm.
50
51Metadata for manager (first node):
52
53.. code-block:: yaml
54
55 docker:
56 host:
57 enabled: true
58 swarm:
59 role: manager
60 advertise_addr: 192.168.1.5
61 bind:
62 address: 192.168.1.5
63 port: 2377
64
Aleš Komárek028b8852017-04-11 13:10:58 +020065Metadata for worker.
Filip Pytloun2720a0d2016-11-02 14:15:55 +010066
67.. code-block:: yaml
68
69 docker:
70 host:
71 enabled: true
72 swarm:
73 role: worker
74 master:
75 host: 192.168.1.5
76 port: 2377
77
78Token to join to master node is obtained from grains using salt.mine. In case
79of any ``join_token undefined`` issues, ensure you have ``docker_swarm_``
80grains available.
81
Aleš Komárek028b8852017-04-11 13:10:58 +020082Docker Client
83-------------
Michael Kutý17649402016-03-19 23:57:43 +010084
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020085Container
86~~~~~~~~~
87
88.. code-block:: yaml
89
Michael Kutý17649402016-03-19 23:57:43 +010090 docker:
Filip Pytloune27a90d2016-08-29 14:08:34 +020091 client:
Michael Kutý17649402016-03-19 23:57:43 +010092 container:
Filip Pytloun87169542016-08-29 13:38:30 +020093 jenkins:
94 # Don't start automatically
95 start: false
96 restart: unless-stopped
97 image: jenkins:2.7.1
Michael Kutý17649402016-03-19 23:57:43 +010098 ports:
Filip Pytloun87169542016-08-29 13:38:30 +020099 - 8081:8080
100 - 50000:50000
101 environment:
102 JAVA_OPTS: "-Dhudson.footerURL=https://www.example.com"
103 volumes:
104 - /srv/volumes/jenkins:/var/jenkins_home
Michael Kutý17649402016-03-19 23:57:43 +0100105
Aleš Komárek028b8852017-04-11 13:10:58 +0200106Using Docker Compose
107~~~~~~~~~~~~~~~~~~~~
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200108
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200109There are two states that provides this functionality:
110
111- docker.client.stack
112- docker.client.compose
113
114Stack is new and works with Docker Swarm Mode. Compose is legacy and works
115only if node isn't member of Swarm.
116Metadata for both states are similar and differs only in implementation.
117
118Stack
119^^^^^
120
121.. code-block:: yaml
122
123 docker:
124 client:
125 stack:
126 django_web:
127 enabled: true
128 update: true
129 environment:
130 SOMEVAR: somevalue
Simon Pasquier48482c22017-08-10 15:14:17 +0200131 version: "3.1"
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200132 service:
133 db:
134 image: postgres
135 web:
136 image: djangoapp
137 volumes:
138 - /srv/volumes/django:/srv/django
139 ports:
140 - 8000:8000
141 depends_on:
142 - db
143
144Compose
145^^^^^^^
146
Filip Pytloun21d9af92016-08-30 08:13:39 +0200147There are three options how to install docker-compose:
148
149- distribution package (default)
150- using Pip
151- using Docker container
152
153Install docker-compose using Docker (default is distribution package)
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200154
155.. code-block:: yaml
156
157 docker:
158 client:
159 compose:
Filip Pytloun21d9af92016-08-30 08:13:39 +0200160 source:
161 engine: docker
162 image: docker/compose:1.8.0
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200163 django_web:
164 # Run up action, any positional argument to docker-compose CLI
165 # If not defined, only docker-compose.yml is generated
166 status: up
Filip Pytlounbe2b4a82016-09-15 18:10:24 +0200167 # Run image pull every time state is run triggering container
168 # restart in case it's changed
169 pull: true
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200170 environment:
171 SOMEVAR: somevalue
172 service:
173 db:
174 image: postgres
175 web:
176 image: djangoapp
177 volumes:
178 - /srv/volumes/django:/srv/django
179 ports:
180 - 8000:8000
181 depends_on:
182 - db
183
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200184Service
185-------
186
Filip Pytlounab52ede2016-11-02 16:59:49 +0100187To deploy service in Swarm mode, you can use ``docker.client.service``:
188
189.. code-block:: yaml
190
191 parameters:
192 docker:
193 client:
194 service:
195 postgresql:
196 environment:
197 POSTGRES_USER: user
198 POSTGRES_PASSWORD: password
199 POSTGRES_DB: mydb
200 restart:
201 condition: on-failure
202 image: "postgres:9.5"
203 ports:
204 - 5432:5432
205 volume:
206 data:
207 type: bind
208 source: /srv/volumes/postgresql/maas
209 destination: /var/lib/postgresql/data
210
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200211
Aleš Komárek028b8852017-04-11 13:10:58 +0200212Docker Registry
213---------------
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200214
215.. code-block:: yaml
216
217 docker:
218 registry:
219 log:
220 level: debug
221 formatter: json
222 cache:
223 engine: redis
224 host: localhost
225 storage:
226 engine: filesystem
227 root: /srv/docker/registry
228 bind:
229 host: 0.0.0.0
230 port: 5000
231 hook:
232 mail:
233 levels:
234 - panic
235 # Options are rendered as yaml as is so use hook-specific options here
236 options:
237 smtp:
238 addr: smtp.sendhost.com:25
239 username: sendername
240 password: password
241 insecure: true
242 from: name@sendhost.com
243 to:
244 - name@receivehost.com
245
marco85b72a62016-07-07 13:08:33 +0200246Docker login to private registry
marco85b72a62016-07-07 13:08:33 +0200247
248.. code-block:: yaml
249
250 docker:
251 host:
252 enabled: true
253 registry:
254 first:
255 address: private.docker.com
256 user: username
257 password: password
258 second:
259 address: private2.docker.com
260 user: username2
261 password: password2
Michael Kutý17649402016-03-19 23:57:43 +0100262
Aleš Komárek028b8852017-04-11 13:10:58 +0200263
264More Information
265================
Michael Kutý17649402016-03-19 23:57:43 +0100266
267* https://docs.docker.com/installation/ubuntulinux/
268* https://github.com/saltstack-formulas/docker-formula
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200269
Filip Pytlound617a762017-02-02 13:02:03 +0100270
271Documentation and Bugs
272======================
273
274To learn how to install and update salt-formulas, consult the documentation
275available online at:
276
277 http://salt-formulas.readthedocs.io/
278
279In the unfortunate event that bugs are discovered, they should be reported to
280the appropriate issue tracker. Use Github issue tracker for specific salt
281formula:
282
283 https://github.com/salt-formulas/salt-formula-docker/issues
284
285For feature requests, bug reports or blueprints affecting entire ecosystem,
286use Launchpad salt-formulas project:
287
288 https://launchpad.net/salt-formulas
289
290You can also join salt-formulas-users team and subscribe to mailing list:
291
292 https://launchpad.net/~salt-formulas-users
293
294Developers wishing to work on the salt-formulas projects should always base
295their work on master branch and submit pull request against specific formula.
296
297 https://github.com/salt-formulas/salt-formula-docker
298
299Any questions or feedback is always welcome so feel free to join our IRC
300channel:
301
302 #salt-formulas @ irc.freenode.net