blob: 6087c5ac6663b90d229d93e294c9023641abab6c [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
138 service:
139 db:
140 image: postgres
141 web:
142 image: djangoapp
143 volumes:
144 - /srv/volumes/django:/srv/django
145 ports:
146 - 8000:8000
147 depends_on:
148 - db
149
150Compose
151^^^^^^^
152
Filip Pytloun21d9af92016-08-30 08:13:39 +0200153There are three options how to install docker-compose:
154
155- distribution package (default)
156- using Pip
157- using Docker container
158
159Install docker-compose using Docker (default is distribution package)
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200160
161.. code-block:: yaml
162
163 docker:
164 client:
165 compose:
Filip Pytloun21d9af92016-08-30 08:13:39 +0200166 source:
167 engine: docker
168 image: docker/compose:1.8.0
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200169 django_web:
170 # Run up action, any positional argument to docker-compose CLI
171 # If not defined, only docker-compose.yml is generated
172 status: up
Filip Pytlounbe2b4a82016-09-15 18:10:24 +0200173 # Run image pull every time state is run triggering container
174 # restart in case it's changed
175 pull: true
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200176 environment:
177 SOMEVAR: somevalue
178 service:
179 db:
180 image: postgres
181 web:
182 image: djangoapp
183 volumes:
184 - /srv/volumes/django:/srv/django
185 ports:
186 - 8000:8000
187 depends_on:
188 - db
189
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200190Service
191-------
192
Filip Pytlounab52ede2016-11-02 16:59:49 +0100193To deploy service in Swarm mode, you can use ``docker.client.service``:
194
195.. code-block:: yaml
196
197 parameters:
198 docker:
199 client:
200 service:
201 postgresql:
202 environment:
203 POSTGRES_USER: user
204 POSTGRES_PASSWORD: password
205 POSTGRES_DB: mydb
206 restart:
207 condition: on-failure
208 image: "postgres:9.5"
209 ports:
210 - 5432:5432
211 volume:
212 data:
213 type: bind
214 source: /srv/volumes/postgresql/maas
215 destination: /var/lib/postgresql/data
216
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200217
Aleš Komárek028b8852017-04-11 13:10:58 +0200218Docker Registry
219---------------
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200220
221.. code-block:: yaml
222
223 docker:
224 registry:
225 log:
226 level: debug
227 formatter: json
228 cache:
229 engine: redis
230 host: localhost
231 storage:
232 engine: filesystem
233 root: /srv/docker/registry
234 bind:
235 host: 0.0.0.0
236 port: 5000
237 hook:
238 mail:
239 levels:
240 - panic
241 # Options are rendered as yaml as is so use hook-specific options here
242 options:
243 smtp:
244 addr: smtp.sendhost.com:25
245 username: sendername
246 password: password
247 insecure: true
248 from: name@sendhost.com
249 to:
250 - name@receivehost.com
251
marco85b72a62016-07-07 13:08:33 +0200252Docker login to private registry
marco85b72a62016-07-07 13:08:33 +0200253
254.. code-block:: yaml
255
256 docker:
257 host:
258 enabled: true
259 registry:
260 first:
261 address: private.docker.com
262 user: username
263 password: password
264 second:
265 address: private2.docker.com
266 user: username2
267 password: password2
Michael Kutý17649402016-03-19 23:57:43 +0100268
Aleš Komárek028b8852017-04-11 13:10:58 +0200269
270More Information
271================
Michael Kutý17649402016-03-19 23:57:43 +0100272
273* https://docs.docker.com/installation/ubuntulinux/
274* https://github.com/saltstack-formulas/docker-formula
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200275
Filip Pytlound617a762017-02-02 13:02:03 +0100276
277Documentation and Bugs
278======================
279
280To learn how to install and update salt-formulas, consult the documentation
281available online at:
282
283 http://salt-formulas.readthedocs.io/
284
285In the unfortunate event that bugs are discovered, they should be reported to
286the appropriate issue tracker. Use Github issue tracker for specific salt
287formula:
288
289 https://github.com/salt-formulas/salt-formula-docker/issues
290
291For feature requests, bug reports or blueprints affecting entire ecosystem,
292use Launchpad salt-formulas project:
293
294 https://launchpad.net/salt-formulas
295
296You can also join salt-formulas-users team and subscribe to mailing list:
297
298 https://launchpad.net/~salt-formulas-users
299
300Developers wishing to work on the salt-formulas projects should always base
301their work on master branch and submit pull request against specific formula.
302
303 https://github.com/salt-formulas/salt-formula-docker
304
305Any questions or feedback is always welcome so feel free to join our IRC
306channel:
307
308 #salt-formulas @ irc.freenode.net