blob: 1b2f8750a1421e915dffdfe19cc8339c466c1a88 [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
Tomáš Kukrál19a39602017-08-27 22:21:47 +020036Configure proxy for docker host
37
38.. code-block:: yaml
39
40 docker:
41 host:
42 proxy:
43 enabled: true
44 http: http://user:pass@proxy:3128
45 https: http://user:pass@proxy:3128
46 no_proxy:
47 - localhost
48 - 127.0.0.1
49 - docker-registry
50
51
Aleš Komárek028b8852017-04-11 13:10:58 +020052Docker Swarm
53------------
Filip Pytloun2720a0d2016-11-02 14:15:55 +010054
55Role can be master, manager or worker. Where master is the first manager that
56will initialize the swarm.
57
58Metadata for manager (first node):
59
60.. code-block:: yaml
61
62 docker:
63 host:
64 enabled: true
65 swarm:
66 role: manager
67 advertise_addr: 192.168.1.5
68 bind:
69 address: 192.168.1.5
70 port: 2377
71
Aleš Komárek028b8852017-04-11 13:10:58 +020072Metadata for worker.
Filip Pytloun2720a0d2016-11-02 14:15:55 +010073
74.. code-block:: yaml
75
76 docker:
77 host:
78 enabled: true
79 swarm:
80 role: worker
81 master:
82 host: 192.168.1.5
83 port: 2377
84
85Token to join to master node is obtained from grains using salt.mine. In case
86of any ``join_token undefined`` issues, ensure you have ``docker_swarm_``
87grains available.
88
Aleš Komárek028b8852017-04-11 13:10:58 +020089Docker Client
90-------------
Michael Kutý17649402016-03-19 23:57:43 +010091
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020092Container
93~~~~~~~~~
94
95.. code-block:: yaml
96
Michael Kutý17649402016-03-19 23:57:43 +010097 docker:
Filip Pytloune27a90d2016-08-29 14:08:34 +020098 client:
Michael Kutý17649402016-03-19 23:57:43 +010099 container:
Filip Pytloun87169542016-08-29 13:38:30 +0200100 jenkins:
101 # Don't start automatically
102 start: false
103 restart: unless-stopped
104 image: jenkins:2.7.1
Michael Kutý17649402016-03-19 23:57:43 +0100105 ports:
Filip Pytloun87169542016-08-29 13:38:30 +0200106 - 8081:8080
107 - 50000:50000
108 environment:
109 JAVA_OPTS: "-Dhudson.footerURL=https://www.example.com"
110 volumes:
111 - /srv/volumes/jenkins:/var/jenkins_home
Michael Kutý17649402016-03-19 23:57:43 +0100112
Aleš Komárek028b8852017-04-11 13:10:58 +0200113Using Docker Compose
114~~~~~~~~~~~~~~~~~~~~
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200115
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200116There are two states that provides this functionality:
117
118- docker.client.stack
119- docker.client.compose
120
121Stack is new and works with Docker Swarm Mode. Compose is legacy and works
122only if node isn't member of Swarm.
123Metadata for both states are similar and differs only in implementation.
124
125Stack
126^^^^^
127
128.. code-block:: yaml
129
130 docker:
131 client:
132 stack:
133 django_web:
134 enabled: true
135 update: true
136 environment:
137 SOMEVAR: somevalue
Simon Pasquier48482c22017-08-10 15:14:17 +0200138 version: "3.1"
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200139 service:
140 db:
141 image: postgres
142 web:
143 image: djangoapp
144 volumes:
145 - /srv/volumes/django:/srv/django
146 ports:
147 - 8000:8000
148 depends_on:
149 - db
150
151Compose
152^^^^^^^
153
Filip Pytloun21d9af92016-08-30 08:13:39 +0200154There are three options how to install docker-compose:
155
156- distribution package (default)
157- using Pip
158- using Docker container
159
160Install docker-compose using Docker (default is distribution package)
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200161
162.. code-block:: yaml
163
164 docker:
165 client:
166 compose:
Filip Pytloun21d9af92016-08-30 08:13:39 +0200167 source:
168 engine: docker
169 image: docker/compose:1.8.0
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200170 django_web:
171 # Run up action, any positional argument to docker-compose CLI
172 # If not defined, only docker-compose.yml is generated
173 status: up
Filip Pytlounbe2b4a82016-09-15 18:10:24 +0200174 # Run image pull every time state is run triggering container
175 # restart in case it's changed
176 pull: true
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200177 environment:
178 SOMEVAR: somevalue
179 service:
180 db:
181 image: postgres
182 web:
183 image: djangoapp
184 volumes:
185 - /srv/volumes/django:/srv/django
186 ports:
187 - 8000:8000
188 depends_on:
189 - db
190
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200191Service
192-------
193
Filip Pytlounab52ede2016-11-02 16:59:49 +0100194To deploy service in Swarm mode, you can use ``docker.client.service``:
195
196.. code-block:: yaml
197
198 parameters:
199 docker:
200 client:
201 service:
202 postgresql:
203 environment:
204 POSTGRES_USER: user
205 POSTGRES_PASSWORD: password
206 POSTGRES_DB: mydb
207 restart:
208 condition: on-failure
209 image: "postgres:9.5"
210 ports:
211 - 5432:5432
212 volume:
213 data:
214 type: bind
215 source: /srv/volumes/postgresql/maas
216 destination: /var/lib/postgresql/data
217
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200218
Aleš Komárek028b8852017-04-11 13:10:58 +0200219Docker Registry
220---------------
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200221
222.. code-block:: yaml
223
224 docker:
225 registry:
226 log:
227 level: debug
228 formatter: json
229 cache:
230 engine: redis
231 host: localhost
232 storage:
233 engine: filesystem
234 root: /srv/docker/registry
235 bind:
236 host: 0.0.0.0
237 port: 5000
238 hook:
239 mail:
240 levels:
241 - panic
242 # Options are rendered as yaml as is so use hook-specific options here
243 options:
244 smtp:
245 addr: smtp.sendhost.com:25
246 username: sendername
247 password: password
248 insecure: true
249 from: name@sendhost.com
250 to:
251 - name@receivehost.com
252
marco85b72a62016-07-07 13:08:33 +0200253Docker login to private registry
marco85b72a62016-07-07 13:08:33 +0200254
255.. code-block:: yaml
256
257 docker:
258 host:
259 enabled: true
260 registry:
261 first:
262 address: private.docker.com
263 user: username
264 password: password
265 second:
266 address: private2.docker.com
267 user: username2
268 password: password2
Michael Kutý17649402016-03-19 23:57:43 +0100269
Aleš Komárek028b8852017-04-11 13:10:58 +0200270
271More Information
272================
Michael Kutý17649402016-03-19 23:57:43 +0100273
274* https://docs.docker.com/installation/ubuntulinux/
275* https://github.com/saltstack-formulas/docker-formula
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200276
Filip Pytlound617a762017-02-02 13:02:03 +0100277
278Documentation and Bugs
279======================
280
281To learn how to install and update salt-formulas, consult the documentation
282available online at:
283
284 http://salt-formulas.readthedocs.io/
285
286In the unfortunate event that bugs are discovered, they should be reported to
287the appropriate issue tracker. Use Github issue tracker for specific salt
288formula:
289
290 https://github.com/salt-formulas/salt-formula-docker/issues
291
292For feature requests, bug reports or blueprints affecting entire ecosystem,
293use Launchpad salt-formulas project:
294
295 https://launchpad.net/salt-formulas
296
297You can also join salt-formulas-users team and subscribe to mailing list:
298
299 https://launchpad.net/~salt-formulas-users
300
301Developers wishing to work on the salt-formulas projects should always base
302their work on master branch and submit pull request against specific formula.
303
304 https://github.com/salt-formulas/salt-formula-docker
305
306Any questions or feedback is always welcome so feel free to join our IRC
307channel:
308
309 #salt-formulas @ irc.freenode.net