blob: 41b956b71dcabf3568dfe8fde8dffde6deb60a13 [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
Michael Kutý17649402016-03-19 23:57:43 +010028
Filip Pytloun2720a0d2016-11-02 14:15:55 +010029Swarm
30-----
31
32Role can be master, manager or worker. Where master is the first manager that
33will initialize the swarm.
34
35Metadata for manager (first node):
36
37.. code-block:: yaml
38
39 docker:
40 host:
41 enabled: true
42 swarm:
43 role: manager
44 advertise_addr: 192.168.1.5
45 bind:
46 address: 192.168.1.5
47 port: 2377
48
49Metadata for worker:
50
51.. code-block:: yaml
52
53 docker:
54 host:
55 enabled: true
56 swarm:
57 role: worker
58 master:
59 host: 192.168.1.5
60 port: 2377
61
62Token to join to master node is obtained from grains using salt.mine. In case
63of any ``join_token undefined`` issues, ensure you have ``docker_swarm_``
64grains available.
65
Filip Pytloune27a90d2016-08-29 14:08:34 +020066Client
67------
Michael Kutý17649402016-03-19 23:57:43 +010068
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020069Container
70~~~~~~~~~
71
72.. code-block:: yaml
73
Michael Kutý17649402016-03-19 23:57:43 +010074 docker:
Filip Pytloune27a90d2016-08-29 14:08:34 +020075 client:
Michael Kutý17649402016-03-19 23:57:43 +010076 container:
Filip Pytloun87169542016-08-29 13:38:30 +020077 jenkins:
78 # Don't start automatically
79 start: false
80 restart: unless-stopped
81 image: jenkins:2.7.1
Michael Kutý17649402016-03-19 23:57:43 +010082 ports:
Filip Pytloun87169542016-08-29 13:38:30 +020083 - 8081:8080
84 - 50000:50000
85 environment:
86 JAVA_OPTS: "-Dhudson.footerURL=https://www.example.com"
87 volumes:
88 - /srv/volumes/jenkins:/var/jenkins_home
Michael Kutý17649402016-03-19 23:57:43 +010089
Filip Pytloun96fc0cc2016-08-29 16:01:10 +020090Compose
91~~~~~~~
92
Filip Pytloun21d9af92016-08-30 08:13:39 +020093There are three options how to install docker-compose:
94
95- distribution package (default)
96- using Pip
97- using Docker container
98
99Install docker-compose using Docker (default is distribution package)
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200100
101.. code-block:: yaml
102
103 docker:
104 client:
105 compose:
Filip Pytloun21d9af92016-08-30 08:13:39 +0200106 source:
107 engine: docker
108 image: docker/compose:1.8.0
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200109 django_web:
110 # Run up action, any positional argument to docker-compose CLI
111 # If not defined, only docker-compose.yml is generated
112 status: up
Filip Pytlounbe2b4a82016-09-15 18:10:24 +0200113 # Run image pull every time state is run triggering container
114 # restart in case it's changed
115 pull: true
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200116 environment:
117 SOMEVAR: somevalue
118 service:
119 db:
120 image: postgres
121 web:
122 image: djangoapp
123 volumes:
124 - /srv/volumes/django:/srv/django
125 ports:
126 - 8000:8000
127 depends_on:
128 - db
129
Filip Pytlounab52ede2016-11-02 16:59:49 +0100130Service
131-------
132
133To deploy service in Swarm mode, you can use ``docker.client.service``:
134
135.. code-block:: yaml
136
137 parameters:
138 docker:
139 client:
140 service:
141 postgresql:
142 environment:
143 POSTGRES_USER: user
144 POSTGRES_PASSWORD: password
145 POSTGRES_DB: mydb
146 restart:
147 condition: on-failure
148 image: "postgres:9.5"
149 ports:
150 - 5432:5432
151 volume:
152 data:
153 type: bind
154 source: /srv/volumes/postgresql/maas
155 destination: /var/lib/postgresql/data
156
Filip Pytloun96fc0cc2016-08-29 16:01:10 +0200157
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200158Registry
159--------
160
161.. code-block:: yaml
162
163 docker:
164 registry:
165 log:
166 level: debug
167 formatter: json
168 cache:
169 engine: redis
170 host: localhost
171 storage:
172 engine: filesystem
173 root: /srv/docker/registry
174 bind:
175 host: 0.0.0.0
176 port: 5000
177 hook:
178 mail:
179 levels:
180 - panic
181 # Options are rendered as yaml as is so use hook-specific options here
182 options:
183 smtp:
184 addr: smtp.sendhost.com:25
185 username: sendername
186 password: password
187 insecure: true
188 from: name@sendhost.com
189 to:
190 - name@receivehost.com
191
marco85b72a62016-07-07 13:08:33 +0200192Docker login to private registry
193--------------------------------
194
195.. code-block:: yaml
196
197 docker:
198 host:
199 enabled: true
200 registry:
201 first:
202 address: private.docker.com
203 user: username
204 password: password
205 second:
206 address: private2.docker.com
207 user: username2
208 password: password2
Michael Kutý17649402016-03-19 23:57:43 +0100209
210Read more
211---------
212
213* https://docs.docker.com/installation/ubuntulinux/
214* https://github.com/saltstack-formulas/docker-formula
Filip Pytlounbaf94c92016-06-07 18:07:17 +0200215