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