blob: 2718b40e9e93798002fe3e3280b5910a248c6f4e [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
Ruslan Khozinov6f34b6f2017-03-27 16:30:19 +000026 experimental: true
Filip Pytloun972294d2016-09-15 17:52:32 +020027 insecure_registries:
28 - 127.0.0.1
Jakub Pavlik18a58eb2016-11-02 15:12:17 +010029 log:
30 engine: json-file
31 size: 50m
Michael Kutý17649402016-03-19 23:57:43 +010032
Aleš Komárek028b8852017-04-11 13:10:58 +020033
34Docker Swarm
35------------
Filip Pytloun2720a0d2016-11-02 14:15:55 +010036
37Role can be master, manager or worker. Where master is the first manager that
38will initialize the swarm.
39
40Metadata for manager (first node):
41
42.. code-block:: yaml
43
44 docker:
45 host:
46 enabled: true
47 swarm:
48 role: manager
49 advertise_addr: 192.168.1.5
50 bind:
51 address: 192.168.1.5
52 port: 2377
53
Aleš Komárek028b8852017-04-11 13:10:58 +020054Metadata for worker.
Filip Pytloun2720a0d2016-11-02 14:15:55 +010055
56.. code-block:: yaml
57
58 docker:
59 host:
60 enabled: true
61 swarm:
62 role: worker
63 master:
64 host: 192.168.1.5
65 port: 2377
66
67Token to join to master node is obtained from grains using salt.mine. In case
68of any ``join_token undefined`` issues, ensure you have ``docker_swarm_``
69grains available.
70
Aleš Komárek028b8852017-04-11 13:10:58 +020071Docker Client
72-------------
Michael Kutý17649402016-03-19 23:57:43 +010073
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020074Container
75~~~~~~~~~
76
77.. code-block:: yaml
78
Michael Kutý17649402016-03-19 23:57:43 +010079 docker:
Filip Pytloune27a90d2016-08-29 14:08:34 +020080 client:
Michael Kutý17649402016-03-19 23:57:43 +010081 container:
Filip Pytloun87169542016-08-29 13:38:30 +020082 jenkins:
83 # Don't start automatically
84 start: false
85 restart: unless-stopped
86 image: jenkins:2.7.1
Michael Kutý17649402016-03-19 23:57:43 +010087 ports:
Filip Pytloun87169542016-08-29 13:38:30 +020088 - 8081:8080
89 - 50000:50000
90 environment:
91 JAVA_OPTS: "-Dhudson.footerURL=https://www.example.com"
92 volumes:
93 - /srv/volumes/jenkins:/var/jenkins_home
Michael Kutý17649402016-03-19 23:57:43 +010094
Aleš Komárek028b8852017-04-11 13:10:58 +020095Using Docker Compose
96~~~~~~~~~~~~~~~~~~~~
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020097
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +020098There are two states that provides this functionality:
99
100- docker.client.stack
101- docker.client.compose
102
103Stack is new and works with Docker Swarm Mode. Compose is legacy and works
104only if node isn't member of Swarm.
105Metadata for both states are similar and differs only in implementation.
106
107Stack
108^^^^^
109
110.. code-block:: yaml
111
112 docker:
113 client:
114 stack:
115 django_web:
116 enabled: true
117 update: true
118 environment:
119 SOMEVAR: somevalue
120 service:
121 db:
122 image: postgres
123 web:
124 image: djangoapp
125 volumes:
126 - /srv/volumes/django:/srv/django
127 ports:
128 - 8000:8000
129 depends_on:
130 - db
131
132Compose
133^^^^^^^
134
Filip Pytloun21d9af92016-08-30 08:13:39 +0200135There are three options how to install docker-compose:
136
137- distribution package (default)
138- using Pip
139- using Docker container
140
141Install docker-compose using Docker (default is distribution package)
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200142
143.. code-block:: yaml
144
145 docker:
146 client:
147 compose:
Filip Pytloun21d9af92016-08-30 08:13:39 +0200148 source:
149 engine: docker
150 image: docker/compose:1.8.0
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200151 django_web:
152 # Run up action, any positional argument to docker-compose CLI
153 # If not defined, only docker-compose.yml is generated
154 status: up
Filip Pytlounbe2b4a82016-09-15 18:10:24 +0200155 # Run image pull every time state is run triggering container
156 # restart in case it's changed
157 pull: true
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200158 environment:
159 SOMEVAR: somevalue
160 service:
161 db:
162 image: postgres
163 web:
164 image: djangoapp
165 volumes:
166 - /srv/volumes/django:/srv/django
167 ports:
168 - 8000:8000
169 depends_on:
170 - db
171
Filip Pytlouna4f6c2f2017-04-13 12:00:01 +0200172Service
173-------
174
Filip Pytlounab52ede2016-11-02 16:59:49 +0100175To deploy service in Swarm mode, you can use ``docker.client.service``:
176
177.. code-block:: yaml
178
179 parameters:
180 docker:
181 client:
182 service:
183 postgresql:
184 environment:
185 POSTGRES_USER: user
186 POSTGRES_PASSWORD: password
187 POSTGRES_DB: mydb
188 restart:
189 condition: on-failure
190 image: "postgres:9.5"
191 ports:
192 - 5432:5432
193 volume:
194 data:
195 type: bind
196 source: /srv/volumes/postgresql/maas
197 destination: /var/lib/postgresql/data
198
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200199
Aleš Komárek028b8852017-04-11 13:10:58 +0200200Docker Registry
201---------------
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200202
203.. code-block:: yaml
204
205 docker:
206 registry:
207 log:
208 level: debug
209 formatter: json
210 cache:
211 engine: redis
212 host: localhost
213 storage:
214 engine: filesystem
215 root: /srv/docker/registry
216 bind:
217 host: 0.0.0.0
218 port: 5000
219 hook:
220 mail:
221 levels:
222 - panic
223 # Options are rendered as yaml as is so use hook-specific options here
224 options:
225 smtp:
226 addr: smtp.sendhost.com:25
227 username: sendername
228 password: password
229 insecure: true
230 from: name@sendhost.com
231 to:
232 - name@receivehost.com
233
marco85b72a62016-07-07 13:08:33 +0200234Docker login to private registry
marco85b72a62016-07-07 13:08:33 +0200235
236.. code-block:: yaml
237
238 docker:
239 host:
240 enabled: true
241 registry:
242 first:
243 address: private.docker.com
244 user: username
245 password: password
246 second:
247 address: private2.docker.com
248 user: username2
249 password: password2
Michael Kutý17649402016-03-19 23:57:43 +0100250
Aleš Komárek028b8852017-04-11 13:10:58 +0200251
252More Information
253================
Michael Kutý17649402016-03-19 23:57:43 +0100254
255* https://docs.docker.com/installation/ubuntulinux/
256* https://github.com/saltstack-formulas/docker-formula
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200257
Filip Pytlound617a762017-02-02 13:02:03 +0100258
259Documentation and Bugs
260======================
261
262To learn how to install and update salt-formulas, consult the documentation
263available online at:
264
265 http://salt-formulas.readthedocs.io/
266
267In the unfortunate event that bugs are discovered, they should be reported to
268the appropriate issue tracker. Use Github issue tracker for specific salt
269formula:
270
271 https://github.com/salt-formulas/salt-formula-docker/issues
272
273For feature requests, bug reports or blueprints affecting entire ecosystem,
274use Launchpad salt-formulas project:
275
276 https://launchpad.net/salt-formulas
277
278You can also join salt-formulas-users team and subscribe to mailing list:
279
280 https://launchpad.net/~salt-formulas-users
281
282Developers wishing to work on the salt-formulas projects should always base
283their work on master branch and submit pull request against specific formula.
284
285 https://github.com/salt-formulas/salt-formula-docker
286
287Any questions or feedback is always welcome so feel free to join our IRC
288channel:
289
290 #salt-formulas @ irc.freenode.net