@@ -14,338 +14,70 @@ weight=10
14
14
15
15
# Deploy an app from the CLI
16
16
17
- In this quickstart, you'll learn how to deploy multi-container applications
18
- with UCP.
19
- While UCP is intended for deploying multi-container applications, the workflow
20
- for developing them begins outside of the UCP installation. This page explains
21
- the recommended workflow for developing applications. Then, it shows you
22
- step-by-step how to deploy the fully developed application.
17
+ With Docker Universal Control Plane you can deploy your apps from the CLI,
18
+ using Docker Compose. In this example we're going to deploy a WordPress
19
+ application.
23
20
24
- ## Understand the development workflow
21
+ ## Get a client certificate bundle
25
22
26
- UCP is at the end of the application development workflow. You should only
27
- deploy, or allowed to be deployed, individual containers or multi-container
28
- applications that have been systematically developed and tested.
23
+ Docker UCP secures your cluster with role-based access control, so that only
24
+ authorized users can deploy applications to the cluster. To be able to run
25
+ Docker commands on the UCP cluster, you need to authenticate your requests using
26
+ client certificates.
29
27
30
- Your development team should develop in a local environment using the Docker
31
- open source software (OSS) components. These components include:
28
+ [ Learn how to set your CLI to use client certificates] ( ../access-ucp/cli-based-access.md ) .
32
29
33
- * Docker Engine
34
- * Docker Machine (if development is on Mac or Windows)
35
- * Docker Swarm
36
- * Docker Compose
37
- * Docker Hub (for publicly available images)
30
+ ## Deploy WordPress
38
31
39
- Developing an application can include using public images from Docker Hub and
40
- developing new custom images. If there are multiple containers involved, the
41
- team should configure and test container port configurations. For applications
42
- that require them, the team may need to create Docker container volumes and
43
- ensure they are of sufficient size.
32
+ The WordPress application we're going to deploy is composed of two services:
44
33
45
- Once the team has developed a microservice application, they should test it
46
- locally at scale on a Swarm cluster .
34
+ * wordpress: The container that runs Apache, PHP, and WordPress.
35
+ * db: A MariaDB database used for data persistence .
47
36
48
- The output of application development should be a Docker Compose file and a set
49
- of images ready for deployment. These images can be stored in Docker Hub. If
50
- your company is using Docker Trusted Registry, the team may want to or be
51
- required to store their application images in the company registry. The team
52
- must ensure store the images in an accessible registry account.
37
+ <!-- would be better if this was a docker-compose v2 file-->
53
38
39
+ After setting up your terminal to authenticate using client certificates,
40
+ create a file named ` docker-compose.yml ` with the following service definition:
54
41
55
- ## Step 1. Before you begin
42
+ ``` yml
43
+ wordpress :
44
+ image : wordpress
45
+ links :
46
+ - db:mysql
47
+ ports :
48
+ - 8080:80
56
49
57
- This example requires that you have UCP deployed.
58
-
59
- When deploying an application to UCP, you work from a local environment using
60
- the UCP client bundle for your UCP user. You should never deploy from the
61
- command-line while directly logged into a UCP node. The deploy on this page,
62
- requires that your local environment includes the following software:
63
-
64
- * Docker Engine
65
- * Docker Compose
66
- * Git
67
-
68
- ## Step 2. Get the client bundle and configure a shell
69
-
70
- In this step, you download the * client bundle* . To issue commands to a UCP node,
71
- your local shell environment must be configured with the same security
72
- certificates as the UCP application itself. The client bundle contains the
73
- certificates and a script to configure a shell environment.
74
-
75
- Download the bundle and configure your environment.
76
-
77
- 1 . If you haven't already done so, log into UCP.
78
-
79
- 2 . Choose ** admin > Profile** from the right-hand menu.
80
-
81
- Any user can download their certificates. So, if you were logged in under a
82
- user name such as ` davey ` the path to download bundle is ** davey >
83
- Profile** . Since you are logged in as ` admin ` , the path is ` admin ` .
84
-
85
- 3 . Click ** Create Client Bundle** .
86
-
87
- The browser downloads the ` ucp-bundle-admin.zip ` file.
88
-
89
- 4 . Open a shell on your local terminal.
90
-
91
- 5 . If you are on Mac or Windows, ensure your shell does not have an active Docker Machine VM.
92
-
93
- $ docker-machine ls
94
- NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
95
- moxie - virtualbox Stopped Unknown
96
- test - virtualbox Running tcp://192.168.99.100:2376 v1.10.1
97
-
98
- While Machine has a stopped and running host, neither is active in the
99
- shell. You know this because neither host shows an * (asterisk) indicating
100
- the shell is configured.
101
-
102
- 6 . Create a directory to hold the deploy information.
103
-
104
- $ mkdir deploy-app
105
-
106
- 7 . Inside of a ` deploy-app ` create a directory to hold your UCP bundle files.
107
-
108
- $ mkdir deploy-app/bundle
109
-
110
- 8 . Change into the ` deploy-app/bundle ` directory and move the downloaded bundle into it.
111
-
112
- $ cd deploy-app/bundle
113
- $ mv ~/Downloads/ucp-bundle-admin.zip .
114
-
115
- 9 . Unzip the client bundle.
116
-
117
- $ unzip bundle.zip
118
- Archive: bundle.zip
119
- extracting: ca.pem
120
- extracting: cert.pem
121
- extracting: key.pem
122
- extracting: cert.pub
123
- extracting: env.sh
124
-
125
- 10 . Change into the directory that was created when the bundle was unzipped
126
-
127
- 11 . Execute the ` env.sh ` script to set the appropriate environment variables for your UCP deployment
128
-
129
- $ source env.sh
130
-
131
- 12 . Verify that you are connected to UCP by using the ` docker info ` command.
132
-
133
- $ docker info
134
- Containers: 11
135
- Running: 11
136
- Paused: 0
137
- Stopped: 0
138
- Images: 22
139
- ... <output snipped>
140
- Plugins:
141
- Volume:
142
- Network:
143
- Kernel Version: 4.2.0-23-generic
144
- Operating System: linux
145
- Architecture: amd64
146
- CPUs: 3
147
- Total Memory: 11.58 GiB
148
- Name: ucp-controller-ucpdemo-0
149
- ID: DYZQ:I5RM:VM6K:MUFZ:JXCU:H45Y:SFU4:CBPS:OMXC:LQ3S:L2HQ:VEWW
150
- Labels:
151
- com.docker.ucp.license_key=QMb9Ux2PKj-IshswTScxsd19n-c8LwtP-pQiDWy2nVtg
152
- com.docker.ucp.license_max_engines=10
153
- com.docker.ucp.license_expires=2016-05-03 19:52:02 +0000 UTC
154
-
155
-
156
- ## Step 3: Learn about the application
157
-
158
- The application you'll be deploying is a voting application. The voting
159
- application is a dockerized microservice application. It uses a parallel web
160
- frontend that sends jobs to asynchronous background workers. The application's
161
- design can accommodate arbitrarily large scale. The diagram below shows the high
162
- level architecture of the application.
163
-
164
- ![ ] ( ../images/app-architecture.jpg )
165
-
166
- The application is fully dockerized with all services running inside of
167
- containers.
168
-
169
- The frontend consists of an Interlock load balancer with * n* frontend web
170
- servers and associated queues. The load balancer can handle an arbitrary number
171
- of web containers behind it (` frontend01 ` - ` frontendN ` ). The web containers run
172
- a simple Python Flask application. Each web container accepts votes and queues
173
- them to a Redis container on the same node. Each web container and Redis queue
174
- pair operates independently.
175
-
176
- The load balancer together with the independent pairs allows the entire
177
- application to scale to an arbitrary size as needed to meet demand.
178
-
179
- Behind the frontend is a worker tier which runs on separate nodes. This tier:
180
-
181
- * scans the Redis containers
182
- * dequeues votes
183
- * deduplicates votes to prevent double voting
184
- * commits the results to a Postgres container running on a separate node
185
-
186
- Just like the front end, the worker tier can also scale arbitrarily.
187
-
188
- When deploying in UCP, you won't need this exact architecture. For example, you
189
- won't need the Interlock load balancer. Part of the work of UCP administrator
190
- may be to polish the application the team created, leaving only what's needed for UCP.
191
-
192
- For example, the team fully <a
193
- href="https://github.com/docker/swarm-microservice-demo-v1 " target="_ blank">
194
- developed and tested through a local environment using the open source Docker
195
- ecosystem</a >. The Docker Compose file they created looks like this:
196
-
197
- ```
198
- #
199
- # Compose file to run the voting app and dependent services
200
- #
201
- version: '2'
202
- services:
203
- web-vote-app:
204
- build: web-vote-app
205
- environment:
206
- WEB_VOTE_NUMBER: "01"
207
- constraint:node: "=frontend01"
208
- vote-worker:
209
- build: vote-worker
210
- environment:
211
- FROM_REDIS_HOST: 1
212
- TO_REDIS_HOST: 1
213
- results-app:
214
- build: results-app
215
- redis01:
216
- image: redis:3
217
- store:
218
- image: postgres:9.5
219
- environment:
220
- - POSTGRES_USER=postgres
221
- - POSTGRES_PASSWORD=pg8675309
50
+ db :
51
+ image : mariadb
52
+ environment :
53
+ MYSQL_ROOT_PASSWORD : example
222
54
` ` `
223
55
224
- In this ` docker-compose.file ` includes a ` build ` command. You should never
225
- ` build ` an image against the UCP controller or its nodes. You can find out if
226
- the team built and stored the images described in the file, or you can build the
227
- images yourself and push them to a registry. After a little work you could come
228
- up with a ` docker-compose.yml ` that looks like this:
56
+ In your command line, navigate to the place where you've created the
57
+ ` docker-compose.yml` file and run:
229
58
59
+ ` ` ` bash
60
+ $ docker-compose --project-name wordpress up -d
230
61
` ` `
231
- version: "2"
232
-
233
- services:
234
- voting-app:
235
- image: docker/example-voting-app-voting-app
236
- ports:
237
- - "80"
238
- networks:
239
- - voteapp
240
- result-app:
241
- image: docker/example-voting-app-result-app
242
- ports:
243
- - "80"
244
- networks:
245
- - voteapp
246
- worker:
247
- image: docker/example-voting-app-worker
248
- networks:
249
- - voteapp
250
- redis:
251
- image: redis
252
- ports:
253
- - "6379"
254
- networks:
255
- - voteapp
256
- container_name: redis
257
- db:
258
- image: postgres:9.4
259
- volumes:
260
- - "db-data:/var/lib/postgresql/data"
261
- networks:
262
- - voteapp
263
- container_name: db
264
- volumes:
265
- db-data:
266
-
267
- networks:
268
- voteapp:
269
- ```
270
-
271
- This revised compose file uses a set of images stored in Docker Hub. They happen
272
- to be in Docker repositories because the sample application was built by a
273
- Docker team. Compose allows you to designate a network and it defaults to
274
- creating an ` overlay ` network. So, you can specify which networks in UCP to run
275
- on. In this case, you won't manually create the networks, you'll let Compose create
276
- the network for you.
277
-
278
- ## Step 4. Deploy the application
279
-
280
- In this step, you deploy the application in UCP.
281
-
282
- 1 . Bring up the shell you configured in the [ Step
283
- 2] ( #step-2-get-the-client-bundle-and-configure-a-shell ) .
284
-
285
- 2 . Clone the sample compose file onto your local machine..
286
62
287
- $ git clone https://github.com/nicolaka/voteapp-base.git
63
+ Test that the WordPress service is up and running, and find where you can
64
+ reach it.
288
65
289
- The clone command creates a ` voteapp-base ` directory containing the Compose
290
- file.
66
+ ` ` ` bash
67
+ $ docker-compose --project-name wordpress ps
291
68
292
- 4 . Change into the ` voteapp-base ` directory.
293
-
294
- $ cd voteapp-base
295
-
296
- 6 . Deploy the application.
297
-
298
- $ docker-compose up
299
- Creating network "voteappbase_voteapp" with the default driver
300
- Pulling db (postgres:9.4)...
301
- ucpdemo-0: Pulling postgres:9.4... : downloaded
302
- ucpdemo-2: Pulling postgres:9.4... : downloaded
303
- ucpdemo-1: Pulling postgres:9.4... : downloaded
304
- Creating db
305
- Pulling redis (redis:latest)...
306
- ucpdemo-0: Pulling redis:latest... : downloaded
307
- ucpdemo-2: Pulling redis:latest... : downloaded
308
- ucpdemo-1: Pulling redis:latest... : downloaded
309
- Creating redis
310
- Pulling worker (docker/example-voting-app-worker:latest)...
311
-
312
- Compose creates the ` voteappbase_voteapp ` network and deploys the application.
313
-
314
- 7 . From UCP, go to the ** Applications** page inside UCP.
315
-
316
- Your new application should appear in the list.
317
-
318
- 8 . Expand to the app to see which nodes the application containers are running in.
319
-
320
- ![ ] ( ../images/votingapp_default.png )
321
-
322
- ## Step 5. Test the application
323
-
324
- Now that the application is deployed and running, it's time to test it. To do
325
- this, you configure a DNS mapping on the node where you are running
326
- ` votingapp_web-vote-app_1 ` container. browser. This maps the "votingapp.local"
327
- DNS name to the public IP address of the ` votingapp_web-vote-app_1 ` node.
328
-
329
- 1 . Configure the DNS name resolution on your local machine for browsing.
330
-
331
- - On Windows machines this is done by adding ` votingapp.local <votingapp_web-vote-app_1-public-ip> ` to the ` C:\Windows\System32\Drivers\etc\hosts file ` . Modifying this file requires administrator privileges. To open the file with administrator privileges, right-click ` C:\Windows\System32\notepad.exe ` and select ` Run as administrator ` . Once Notepad is open, click ` file ` > ` open ` and open the file and make the edit.
332
-
333
- - On OSX machines this is done by adding ` votingapp.local <votingapp_web-vote-app_1-public-ip> ` to ` /private/etc/hosts ` .
334
-
335
- - On most Linux machines this is done by adding ` votingapp.local <votingapp_web-vote-app_1-public-ip> ` to ` /etc/hosts ` .
336
-
337
- Be sure to replace ` <votingapp_web-vote-app_1-public-ip> ` with the public IP address of
338
- your ` votingapp_web-vote-app_1 ` node. You can find the ` votingapp_web-vote-app_1 ` node's Public IP by
339
- selecting the node from within the UCP dashboard.
69
+ Name Command State Ports
70
+ ------------------------------------------------------------------------------------------
71
+ wordpress_db_1 docker-entrypoint.sh mysqld Up 3306/tcp
72
+ wordpress_wordpress_1 /entrypoint.sh apache2-for ... Up 192.168.99.106:8080->80/tcp
73
+ ` ` `
340
74
341
- 2 . Verify the mapping worked with a ` ping ` command from your local machine.
75
+ In this example, WordPress can be accessed at 192.168.99.106:8080. Navigate to
76
+ this address in your browser, to start using the WordPress app you just
77
+ deployed.
342
78
343
- ping votingapp.local
344
- Pinging votingapp.local [54.183.164.230] with 32 bytes of data:
345
- Reply from 54.183.164.230: bytes=32 time=164ms TTL=42
346
- Reply from 54.183.164.230: bytes=32 time=163ms TTL=42
347
- Reply from 54.183.164.230: bytes=32 time=169ms TTL=42
79
+ 
348
80
349
- 3 . Point your web browser to ` http://votingapp.local ` .
81
+ # # Where to go next
350
82
351
- ![ ] ( ../images/vote -app-test.jpg )
83
+ * [Deploy an app from the UI](deploy -app-ui.md )
0 commit comments