blob: 5cea699f875be0e7f3c7fdff5954596cca99aab0 [file] [log] [blame]
Michael Kutý17649402016-03-19 23:57:43 +01001
2======
3Docker
4======
5
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
15Sample pillar
16-------------
17
Filip Pytloune27a90d2016-08-29 14:08:34 +020018Host
19----
20
Michael Kutý17649402016-03-19 23:57:43 +010021.. code-block:: yaml
22
23 docker:
24 host:
25 enabled: true
Filip Pytloun972294d2016-09-15 17:52:32 +020026 insecure_registries:
27 - 127.0.0.1
Jakub Pavlik18a58eb2016-11-02 15:12:17 +010028 log:
29 engine: json-file
30 size: 50m
Michael Kutý17649402016-03-19 23:57:43 +010031
Filip Pytloun2720a0d2016-11-02 14:15:55 +010032Swarm
33-----
34
35Role can be master, manager or worker. Where master is the first manager that
36will initialize the swarm.
37
38Metadata for manager (first node):
39
40.. code-block:: yaml
41
42 docker:
43 host:
44 enabled: true
45 swarm:
46 role: manager
47 advertise_addr: 192.168.1.5
48 bind:
49 address: 192.168.1.5
50 port: 2377
51
52Metadata for worker:
53
54.. code-block:: yaml
55
56 docker:
57 host:
58 enabled: true
59 swarm:
60 role: worker
61 master:
62 host: 192.168.1.5
63 port: 2377
64
65Token to join to master node is obtained from grains using salt.mine. In case
66of any ``join_token undefined`` issues, ensure you have ``docker_swarm_``
67grains available.
68
Filip Pytloune27a90d2016-08-29 14:08:34 +020069Client
70------
Michael Kutý17649402016-03-19 23:57:43 +010071
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020072Container
73~~~~~~~~~
74
75.. code-block:: yaml
76
Michael Kutý17649402016-03-19 23:57:43 +010077 docker:
Filip Pytloune27a90d2016-08-29 14:08:34 +020078 client:
Michael Kutý17649402016-03-19 23:57:43 +010079 container:
Filip Pytloun87169542016-08-29 13:38:30 +020080 jenkins:
81 # Don't start automatically
82 start: false
83 restart: unless-stopped
84 image: jenkins:2.7.1
Michael Kutý17649402016-03-19 23:57:43 +010085 ports:
Filip Pytloun87169542016-08-29 13:38:30 +020086 - 8081:8080
87 - 50000:50000
88 environment:
89 JAVA_OPTS: "-Dhudson.footerURL=https://www.example.com"
90 volumes:
91 - /srv/volumes/jenkins:/var/jenkins_home
Michael Kutý17649402016-03-19 23:57:43 +010092
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020093Compose
94~~~~~~~
95
Filip Pytloun21d9af92016-08-30 08:13:39 +020096There are three options how to install docker-compose:
97
98- distribution package (default)
99- using Pip
100- using Docker container
101
102Install docker-compose using Docker (default is distribution package)
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200103
104.. code-block:: yaml
105
106 docker:
107 client:
108 compose:
Filip Pytloun21d9af92016-08-30 08:13:39 +0200109 source:
110 engine: docker
111 image: docker/compose:1.8.0
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200112 django_web:
113 # Run up action, any positional argument to docker-compose CLI
114 # If not defined, only docker-compose.yml is generated
115 status: up
Filip Pytlounbe2b4a82016-09-15 18:10:24 +0200116 # Run image pull every time state is run triggering container
117 # restart in case it's changed
118 pull: true
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200119 environment:
120 SOMEVAR: somevalue
121 service:
122 db:
123 image: postgres
124 web:
125 image: djangoapp
126 volumes:
127 - /srv/volumes/django:/srv/django
128 ports:
129 - 8000:8000
130 depends_on:
131 - db
132
Filip Pytlounab52ede2016-11-02 16:59:49 +0100133Service
134-------
135
136To deploy service in Swarm mode, you can use ``docker.client.service``:
137
138.. code-block:: yaml
139
140 parameters:
141 docker:
142 client:
143 service:
144 postgresql:
145 environment:
146 POSTGRES_USER: user
147 POSTGRES_PASSWORD: password
148 POSTGRES_DB: mydb
149 restart:
150 condition: on-failure
151 image: "postgres:9.5"
152 ports:
153 - 5432:5432
154 volume:
155 data:
156 type: bind
157 source: /srv/volumes/postgresql/maas
158 destination: /var/lib/postgresql/data
159
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200160
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200161Registry
162--------
163
164.. code-block:: yaml
165
166 docker:
167 registry:
168 log:
169 level: debug
170 formatter: json
171 cache:
172 engine: redis
173 host: localhost
174 storage:
175 engine: filesystem
176 root: /srv/docker/registry
177 bind:
178 host: 0.0.0.0
179 port: 5000
180 hook:
181 mail:
182 levels:
183 - panic
184 # Options are rendered as yaml as is so use hook-specific options here
185 options:
186 smtp:
187 addr: smtp.sendhost.com:25
188 username: sendername
189 password: password
190 insecure: true
191 from: name@sendhost.com
192 to:
193 - name@receivehost.com
194
marco85b72a62016-07-07 13:08:33 +0200195Docker login to private registry
196--------------------------------
197
198.. code-block:: yaml
199
200 docker:
201 host:
202 enabled: true
203 registry:
204 first:
205 address: private.docker.com
206 user: username
207 password: password
208 second:
209 address: private2.docker.com
210 user: username2
211 password: password2
Michael Kutý17649402016-03-19 23:57:43 +0100212
213Read more
214---------
215
216* https://docs.docker.com/installation/ubuntulinux/
217* https://github.com/saltstack-formulas/docker-formula
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200218