forked from ibm-cloud-docs/containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
container_single_ui.html
1661 lines (1618 loc) · 154 KB
/
container_single_ui.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html lang="en-us" xml:lang="en-us">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="dcterms.date" content="2017-11-10">
<meta name="dcterms.rights" content="© Copyright IBM Corporation 2014, 2018">
<meta name="description" content="Use a single container to run simple tests as you develop an app or service or for short-term processes that do not require high availability. To use your own networking front end, you can assign a public IP address to the container.">
<meta name="keywords" content="single container, dashboard, GUI, IBM Containers, containers, CLI, docker run, bx ic, run, updating, command line, container, links, linking, --link, ip address, public, ip-bind, ip-request, ips, ip-unbind, remove, release, docker rm, rm, removing, tutorial, getting started, cli, install, plug-in, images, deploy, docker compose, multi-container deployment, multi-container app, docker-compose.yml, scaling, load balancer, nginx, workload, yml, supported options, faq">
<meta name="geo.country" content="ZZ">
<script>
digitalData = {
page: {
pageInfo: {
language: "en-us",
version: "v18",
ibm: {
country: "ZZ",
type: "CT701"
}
}
}
};
</script><!-- Licensed Materials - Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css">
<title>Running short-term tasks as single containers in IBM Cloud Container Service</title>
</head>
<body><main role="main"><div><article class="nested0" role="article" aria-labelledby="d72924e6" id="container_single_ui"><h1 class="topictitle1" id="d72924e6">Running short-term tasks as single containers (Deprecated)</h1>
<div class="abstract"><div class="shortdesc"><span class="ph">Use a single container to run simple tests as you develop an app or
service or for short-term processes that do not require high availability. To use your own
networking front end, you can assign a public IP address to the container.</span></div>
<div class="p"><div class="note attention"><span class="attentiontitle">Attention:</span> Single and scalable containers are deprecated. Support
will continue in IBM Cloud Public until 5 December 2017 and in IBM Cloud Local and Dedicated until
20 June 2018. Start using Kubernetes clusters today to deploy secure, highly available apps. <a href="https://www.ibm.com/blogs/bluemix/2017/07/deprecation-single-scalable-group-container-service-bluemix-public/" rel="external" target="_blank" title="(Opens in a new tab or window)">Learn more about Kubernetes and how to migrate your
apps</a>.</div>
</div>
<div class="p">In this
page:<div class="lines"> • Running short-term tasks as single containers from the <a href="container_single_ui.html#gui" title="Create and deploy containers from the Cloud GUI.">GUI</a> or the <a href="container_single_ui.html#container_single_cli" title="Create a container by using the run command. A container must include an image in it. If you do not have one yet, you can use one of the default IBM certified images that are available by default in your organization's private images registry.">CLI</a><br>
• <a href="container_single_ui.html#container_single_updating" title="To update an app, you must deploy a new container. If you push a new image, the container is not restarted automatically.">Updating containers</a><br>
• <a href="container_single_ui.html#container_linking" title="When a container is linked to another container in the same space, IBM Cloud Container Service creates a host entry on the recipient container for the source container. You can use an alias to refer to the source container, rather than a specific IP address that might change frequently.">Linking containers</a><br>
• <a href="container_single_ui.html#container_cli_ips" title="Request and bind a public IP address to a container in Cloud.">Requesting and binding IP addresses</a><br>
• <a href="container_single_ui.html#container_single_remove" title="To maximize the use of your quota, remove containers that are not in use occasionally.">Removing single containers</a><br>
• Tutorial: <a href="container_single_ui.html#container_gettingstarted_tutorial" title="IBM Cloud gives you the ability to run Docker containers in the public cloud. Use containers to deploy self-contained, secure web apps that run independently of the host operating system. Containers are lightweight and do not require a lot of system resources because containers use the same system kernel and so can be run more efficiently than a virtual machine. This tutorial showcases how to build a messaging web app using Docker containers in Cloud. In the process, you will write a Dockerfile, add Docker images to your private Cloud images registry and link containers together.">Creating a single container web application</a><br>
• Tutorial: <a href="container_single_ui.html#container_compose_intro" title="If you have apps with multiple components, such as databases, services and caches, orchestrating all containers to start up and shut down together, can be a hard thing to do. In this tutorial, you learn how to deploy and run your app as a multi-container deployment in a microservices architecture by using a single Docker Compose command. Each container that is part of this system, is based on a Docker Compose service definition, and runs in its own isolated environment.">Creating a multi-container deployment</a></div>
</div>
</div>
<aside role="complementary" aria-labelledby="d72924e6"></aside><article class="topic task nested1" role="article" aria-labelledby="d72924e149" id="gui"><h2 class="topictitle2" id="d72924e149">Running short-term tasks as single containers from the <span class="keyword">Cloud</span> GUI</h2>
<div class="body taskbody"><p class="shortdesc">Create and deploy containers from the <span class="keyword">Cloud</span> GUI. </p>
<div class="section prereq" id="gui__prereq_oh5_421_4z"><div class="p">Before you begin, consider the following information. <ul id="gui__ul_ph5_421_4z"><li id="gui__role">You must have a Developer role for the <span class="keyword">Cloud</span> space to create a container in it. For
more information on the permissions of each roles and how to edit roles, see <span class="ph"><a href="../iam/users_roles.html">Users and roles</a></span>.</li>
<li id="gui__add_image">From the <span class="keyword">Cloud</span>
GUI, you create a container from either the IBM-provided public images, or from an existing image in
your organizations private <span class="keyword">Cloud</span>
registry. For more information about adding an image to your <span class="keyword wintitle">Catalog</span>, see <a href="container_images_adding_ov.html" title="A container image is the basis for every container that you create. An image is created from a Dockerfile, which is a file that contains instructions to build the image, and build artifacts, such as an app, the app's configuration, and its dependencies. Think of a container image as an executable file (.exe or .bin). As soon as you run the executable app file, you create an instance of your app. When you run a container, you create a container instance from the image.">Adding Docker images to your organization's private Cloud images registry (Deprecated)</a>.</li>
<li id="gui__existing_ip">Check to see whether an IP address for the space exists that you can use
instead of creating a new one. For more information, see <a href="container_single_ui.html#container_cli_ips_list" title="To make single containers accessible from the Internet, you must bind a public IP address to it. Before you request an IP address, review the list of public IP addresses already assigned to your organization and see whether one of those existing IP addresses are available.">Finding existing public IP addresses for your organization with the command line interface (CLI)</a>.</li>
<li id="gui__bind_service">If you know that you want to bind a <span class="keyword">Cloud</span> service to the container, add the
<span class="keyword">Cloud</span> service to your space. For more
information, see <a href="container_integrations.html#container_integrations_binding" title="IBM Cloud has a list of services and manages them on behalf of app developers. To add a Cloud service for your container to use, you must request an instance of this service and bind the service to the container.">Binding a service from the Cloud GUI</a>.</li>
<li>If you know that you want a shared disk that allows files to be accessible
from within a container, create a volume before you create the container. For more information, see
<a href="container_volumes_ov.html#container_volumes_cli" title="A volume is a persistent storage location for the data that an app creates or the files that the app requires to run. You can create a volume for your container from the command line.">Creating volumes with the command line (CLI)</a>.</li>
</ul>
</div>
</div><p class="li stepsection">To create and deploy a container with an image:</p><ol class="steps" id="gui__steps_qh5_421_4z"><li class="step stepexpand" id="gui__start"><span class="cmd"><span class="ph" data-hd-otherprops="registry_check">From the catalog, select
<span class="ph uicontrol">Containers</span> and choose an image.</span></span> Both images that are provided by IBM and images that are stored in your private <span class="keyword">Cloud</span> registry are displayed. </li>
<li class="step stepexpand" id="gui__namespace"><span class="cmd">If a namespace is already set for your organization, you are not prompted to create one and can
continue with the next step. </span> If a namespace is not specified for your organization yet, you are prompted to set one for the
image registry. A namespace is a unique name to identify your private registry in <span class="keyword">Cloud</span>. The namespace is assigned one time for
an organization and cannot be changed after it is created. If you want to use <span class="keyword">IBM
Cloud Container Service</span> in multiple <span class="keyword">Cloud</span> regions, you must set up a namespace for
each region. <div class="note tip" id="gui__namespace_naming"><span class="tiptitle">Tip:</span> Observe the following rules for the
namespace:<ul id="gui__ul_rh5_421_4z"><li>It can contain only lowercase letters, numbers, or underscores (_).</li>
<li>It can be 4 - 30 characters. If you plan to manage containers from the command line, you might
prefer to have a short namespace that can be typed quickly.</li>
<li>Its name must be unique in <span class="keyword">Cloud</span>.</li>
</ul>
</div>
</li>
<li class="step stepexpand"><span class="cmd">Next, start defining your container.</span> The window opens to the <span class="ph uicontrol">Single</span> container tab, by default.</li>
<li class="step stepexpand" id="gui__tag">Optional: <span class="cmd">Under the image name, select the tag or version of the image to use.</span></li>
<li class="step stepexpand" id="gui__space"><span class="cmd">Select one of the <span class="keyword">Cloud</span> spaces
in your organization.</span></li>
<li class="step stepexpand"><span class="cmd">In the <span class="ph uicontrol">Container name</span> field, enter the name for the container.</span> <div class="note tip"><span class="tiptitle">Tip:</span> The container name must start with a letter, and then can include
uppercase letters, lowercase letters, numbers, periods (.), underscores (_), or hyphens
(-).</div>
</li>
<li class="step stepexpand" id="gui__size"><span class="cmd">In the <span class="ph uicontrol">Size</span> field, select a container size.</span> The default size is <span class="ph uicontrol" data-hd-audience="yellow">Micro (256 MB Memory, 16 GB
Storage)</span>. The size that you choose impacts the amount of memory and disk space the
container gets on the compute host during runtime, and cannot be changed after the container is
created. Other available sizes are<ul data-hd-audience="yellow" id="gui__ul_sh5_421_4z"><li>Pico (64 MB memory, 4 GB disk space)</li>
<li>Nano (128 MB memory, 8 GB disk space)</li>
<li>Tiny (512 MB memory, 32 GB disk space)</li>
<li>Small (1 GB memory, 64 GB disk space)</li>
<li>Medium (2 GB memory, 128 GB disk space)</li>
<li>Large (4 GB memory, 256 GB disk space)</li>
<li>X-Large (8 GB memory, 512 GB disk space)</li>
<li>2X-Large (16 GB memory, 1 TB disk space)</li>
</ul>
</li>
<li class="step stepexpand"><span class="cmd">In the <span class="ph uicontrol">Public IP address</span> field, choose whether to request and assign a
new public IP address. </span> Public IP addresses allow a public connection with the container. One instance when you might
not want a public IP address is when you are using a database that is visible to the user's app only
inside the private network.<div class="steps note"><span class="notetitle">Note:</span> Binding a public IP address does not include a SSL certificate
which encrypts the data that are sent to and from your single container. If your app requires SSL
encryption, you can either implement your own SSL solution or use a container group instead of a
single container. Container groups are bound to a public route that already includes a SSL
certificate, so you can access your container group with HTTPS without any additional configuration.
For more information, see <a href="container_ha.html#container_group_ui" title="Create and deploy a scalable group container from the Cloud GUI. A container group includes two or more containers that run the same image. Use container groups for running long-term services with workloads that require scalability and reliability or for testing at the required scale.">Creating a
container group with the GUI</a>.</div>
<p>If you have an IP address you can use, select
<span class="ph uicontrol">Leave unassigned</span> and bind it to the container after the container is
created.</p>
</li>
<li class="step stepexpand"><span class="cmd">In the <span class="ph uicontrol">Public ports</span> field, specify any public ports to publish. </span> The field is pre-populated with the ports that were specified in the Dockerfile for the image
when the image was built. When you specify a public port, you can choose between UDP and TCP to
indicate the IP protocol that you want to use. If you do not specify a protocol, your port is
automatically exposed for TCP traffic. When you expose a public port, you create a Public Network
Security Group for your container that allows you to send and receive public data on the exposed
port only. All other public ports are closed and cannot be used to access your app from the
internet. You can include multiple ports by separating each port with a comma (,). <div class="p" id="gui__ports_p">If a port is specified in the Dockerfile for the image that you are using, include
that port.<div class="note tip"><span class="tiptitle">Tip:</span> <ul id="gui__ul_uh5_421_4z"><li>For the IBM certified Liberty Server image or a modified
version of this image, enter the port <kbd class="ph userinput">9080</kbd>.</li>
<li>For the IBM certified Node.js image or a modified version
of this image, enter any port, such as port <kbd class="ph userinput">8000</kbd>.</li>
</ul>
</div>
</div>
</li>
<li class="step stepexpand">Optional: <span class="cmd">If you want to add a volume, add environment variables, or bind a <span class="keyword">Cloud</span> service, expand <span class="ph uicontrol">Advanced
Options</span>.</span></li>
<li class="step stepexpand" id="gui__volume">Optional: <span class="cmd">Define data or file storage. Associate an existing volume with a container or container
group.</span> A volume is a shared disk that allows files to be accessible from within a container. The path
in the container indicates where in the container’s file system the volume is mounted. <div class="note restriction"><span class="restrictiontitle">Restriction:</span> You can delete volumes from your <span class="keyword">Cloud</span> space by using the command line
only.</div>
<ol type="a" class="ol substeps" id="gui__substeps_vh5_421_4z"><li class="li substep"><span class="cmd">Click <span class="ph uicontrol">Assign an existing volume</span>.</span></li>
<li class="li substep"><span class="cmd">Select the volume from the drop-down list.</span></li>
<li class="li substep"><span class="cmd">In the next field, specify a path on the container to map the volume. </span> For example, <span class="ph filepath">/var/lib/my_volume</span></li>
<li class="li substep"><span class="cmd">To specify that a volume is read-only, select <span class="ph uicontrol">Read-only</span>.</span> By default, volumes are read/write.</li>
<li class="li substep"><span class="cmd">To add multiple volumes, click <span class="ph uicontrol">Assign an existing volume</span> and repeat
these steps.</span></li>
</ol>
</li>
<li class="step stepexpand" id="gui__env_var">Optional: <span class="cmd">Define environment variables. </span> <ol type="a" class="ol substeps" id="gui__substeps_wh5_421_4z"><li class="li substep substepexpand"><span class="cmd">Click <span class="ph uicontrol">Add a new environment variable</span>.</span></li>
<li class="li substep substepexpand"><span class="cmd">Enter a name for the environment variable.</span></li>
<li class="li substep substepexpand"><span class="cmd">In the next field, specify a value for the environment variable.</span></li>
<li class="li substep substepexpand"><span class="cmd">To add multiple environment variables, click <span class="ph uicontrol">Add a new environment
variable</span> and repeat these steps.</span> <div class="tablenoborder"><table summary="" id="gui__env_keys_group" class="defaultstyle"><caption><span class="tablecap">Table 1. Suggested environment variables</span></caption><thead><tr><th id="d72924e493" class="thleft">Environment variable</th>
<th id="d72924e495" class="thleft">Description</th>
</tr>
</thead>
<tbody><tr><td headers="d72924e493 "><div class="lines"><samp class="ph codeph">CCS_BIND_APP=</samp><br>
<samp class="ph codeph"><var class="keyword varname"><appname></var></samp></div>
</td>
<td headers="d72924e495 ">Some <span class="keyword">Cloud</span> services do not
support direct binding to a container. In this case, you need to create a Cloud Foundry app and bind
the <span class="keyword">Cloud</span> service to it. Then, you
bind the app to your container by using <samp class="ph codeph">CCS_BIND_APP</samp>. The Cloud Foundry app acts as
a bridge and allows <span class="keyword">Cloud</span> to inject
your bridge app’s VCAP_SERVICES information into the running container instance. </td>
</tr>
<tr><td headers="d72924e493 "><div class="lines"><samp class="ph codeph">CCS_BIND_SRV=</samp><br>
<samp class="ph codeph"><var class="keyword varname"><service_instance_name1>,</var></samp><br>
<samp class="ph codeph"><var class="keyword varname"><service_instance_name2></var></samp></div>
<div class="steps note"><span class="notetitle">Note:</span> When a service does not support the use of the <samp class="ph codeph">CCS_BIND_SRV=</samp> environment
variable, use <samp class="ph codeph">CCS_BIND_APP=</samp> instead.</div>
</td>
<td headers="d72924e495 ">To bind a <span class="keyword">Cloud</span> service
directly to a container without using a bridge app, use <samp class="ph codeph">CCS_BIND_SRV</samp>. This binding
allows <span class="keyword">Cloud</span> to inject the
VCAP_SERVICES information into the running container instance. To list multiple <span class="keyword">Cloud</span> services, include them as part of the
same environment variable.</td>
</tr>
<tr><td headers="d72924e493 "><div class="lines">(Deprecated) <samp class="ph codeph">CCS_SSH_KEY=</samp><br>
<samp class="ph codeph"><var class="keyword varname"><public_ssh_key> </var></samp></div>
</td>
<td headers="d72924e495 "><div class="note note" data-hd-status="deprecated"><span class="notetitle">This environment variable has been deprecated:</span> Use <span class="ph"><samp class="ph codeph">bx ic</samp></span>
<samp class="ph codeph">exec</samp> or <span class="ph"><samp class="ph codeph">bx ic</samp></span>
<samp class="ph codeph">attach</samp> for external access to your containers instead. For more information, see
<a href="container_security.html#container_cli_login_exec" title="If you must log in to your running container, you can use bx ic exec.">Logging in to a container with exec</a>.</div>
<span class="ph">To add an SSH
key to a container when you create it, you can use <samp class="ph codeph">CCS_API_KEY</samp>.</span></td>
</tr>
<tr><td headers="d72924e493 "><div class="lines"><samp class="ph codeph">LOG_LOCATIONS=</samp><br>
<samp class="ph codeph"><var class="keyword varname"><path_to_file> </var></samp></div>
</td>
<td headers="d72924e495 "><span class="ph" id="gui__d42700e1424">To add a log file to be monitored in the container, include the
<samp class="ph codeph">LOG_LOCATIONS</samp> environment variable with a path to the log file.</span></td>
</tr>
</tbody>
</table>
</div>
</li>
</ol>
</li>
<li class="step stepexpand" id="gui__bind_service_step">Optional: <span class="cmd">Define other services for the app. Bind a <span class="keyword">Cloud</span> service from your <span class="keyword">Cloud</span> space to your container. In the
<span class="ph uicontrol">Service binding</span> section, select a <span class="keyword">Cloud</span> service instance and click
<span class="ph uicontrol">Add</span> to bind the service to your container.</span> If you do not have any <span class="keyword">Cloud</span>
services added to the space yet, no services are displayed in the menu.</li>
<li class="step stepexpand" id="gui__deploy"><span class="cmd">Deploy the container and wait for it to complete. Click <span class="ph uicontrol">CREATE</span>.</span> As the container is created, which might take a few moments, the container is also
started in <span class="keyword">Cloud</span>. Look in the
<span class="ph uicontrol">CONTAINER HEALTH</span> section for the container’s status. When the creation is
complete, the status is <span class="ph uicontrol">Running</span>.</li>
</ol>
<div class="section result" id="gui__result_xh5_421_4z"><p>If you selected <span class="ph uicontrol">Leave unassigned</span> for the <span class="ph uicontrol">Public IP
Address</span> because you have an existing IP address to use, bind the IP address to the
container. For more information, see <a href="container_single_ui.html#container_cli_ips" title="Request and bind a public IP address to a container in Cloud.">Requesting and binding public IP addresses to containers</a>.</p>
<div class="p" id="gui__wait">If you are connecting to an external app from the container, there is up to a 5-minute
wait after you started the container process before it can connect to the specified IP address.
Then, you can verify that the app is functioning in the container by doing one of the following
options: <ul id="gui__ul_yh5_421_4z"><li>You can open the app in a browser by creating a URL with the public IP address and the port.
<p>Example</p>
<span class="ph filepath">http://<var class="keyword varname">public_IP</var>:<var class="keyword varname">public_port</var></span>
<div class="steps note"><span class="notetitle">Note:</span> If a service in the app exists that does not expose an HTTP endpoint, this option might not
display the app in the browser.</div>
</li>
<li>From the Linux or UNIX command line, you can run <span class="ph filepath">nc -zv
<var class="keyword varname"><public_IP></var>
<var class="keyword varname"><public_port></var></span> to verify that a server is listening on the port that
was specified.</li>
</ul>
</div>
</div><div class="section postreq" id="gui__postreq_zh5_421_4z"><p>Next, if you are an organization manager you can view your organization's container billing.</p>
<ol id="gui__ol_a35_421_4z"><li><span class="ph">From your account details, in
manage organizations, select an organization.</span></li>
<li>Select <span class="ph uicontrol">Usage Dashboard</span> and review the usage and billing details. </li>
</ol>
</div></div>
</article><article class="topic task nested1" role="article" aria-labelledby="d72924e728" lang="en-us" id="container_single_cli"><h2 class="topictitle2" id="d72924e728">Running short-term tasks as single containers with the command line interface (CLI)</h2>
<div class="body taskbody"><p class="shortdesc">Create a container by using the <samp class="ph codeph">run</samp> command. A container must include an
image in it. If you do not have one yet, you can use one of the default IBM certified images that are available by default in your organization's
private images registry.</p>
<div class="section prereq"><div class="p" id="container_single_cli__prereq">Before you begin, consider the following steps. <ul><li>You must have a Developer role for the <span class="keyword">Cloud</span> space to create a container in it. For
more information on the permissions of each roles and how to edit roles, see <span class="ph"><a href="../iam/users_roles.html">Users and roles</a></span>.</li>
<li id="container_single_cli__identify_images">Identify an existing image from your organization's private images registry
to use in your container by running the <samp class="ph codeph"><span class="ph"><samp class="ph codeph">bx ic</samp></span> images</samp> command. To add an image to
your registry, see <a href="container_images_adding_ov.html" title="A container image is the basis for every container that you create. An image is created from a Dockerfile, which is a file that contains instructions to build the image, and build artifacts, such as an app, the app's configuration, and its dependencies. Think of a container image as an executable file (.exe or .bin). As soon as you run the executable app file, you create an instance of your app. When you run a container, you create a container instance from the image.">Adding Docker images to your organization's private Cloud images registry (Deprecated)</a>.</li>
<li>Check to see whether an IP address for the space exists that you can use
instead of creating a new one. For more information, see <a href="container_single_ui.html#container_cli_ips_list" title="To make single containers accessible from the Internet, you must bind a public IP address to it. Before you request an IP address, review the list of public IP addresses already assigned to your organization and see whether one of those existing IP addresses are available.">Finding existing public IP addresses for your organization with the command line interface (CLI)</a>.</li>
<li>If you know that you want to bind a <span class="keyword">Cloud</span> service to the container, add the
<span class="keyword">Cloud</span> service to your space. For more
information, see <a href="container_integrations.html#container_integrations_binding" title="IBM Cloud has a list of services and manages them on behalf of app developers. To add a Cloud service for your container to use, you must request an instance of this service and bind the service to the container.">Binding a service from the Cloud GUI</a>.</li>
<li id="container_single_cli__create_shared_volume">If you know that you want a shared disk that
allows files to be accessible from multiple containers, create a volume before you create the
container. For more information, see <a href="container_volumes_ov.html#container_volumes_cli" title="A volume is a persistent storage location for the data that an app creates or the files that the app requires to run. You can create a volume for your container from the command line.">Creating volumes with the command line (CLI)</a>.</li>
</ul>
</div>
</div><p class="li stepsection">Create a container.</p><ol class="steps"><li class="step stepexpand"><span class="cmd">Create a container with an existing IP address and an existing image in your organization's
private images registry.*</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> run -p <var class="keyword varname"><ip-address></var>:<var class="keyword varname"><port_on_IP></var>:<var class="keyword varname"><public_port></var> -e <var class="keyword varname"><env_variable></var> -m <var class="keyword varname"><container_size></var> --name <var class="keyword varname"><container_name></var> --volume <var class="keyword varname"><volname:mount_path></var> registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><namespace></var>/<var class="keyword varname"><image_name_or_id></var></code></pre>
<div class="steps note"><span class="notetitle">Note:</span> <span class="ph" id="container_single_cli__d41670e180">*In this command, you can replace <samp class="ph codeph"><span class="ph">bx ic</span></samp> with <samp class="ph codeph">docker</samp>
when you <a href="container_cli_cfic_install.html#container_cli_login" title="After you install the CLI, log in to use it.">logged in to <span class="keyword">IBM
Cloud Container Service</span></a> and set your environment
variables to use native Docker commands.</span><span class="ph" id="container_single_cli__d41670e192">You can use native Docker
commands in all steps that are marked with an asterisk (*) in this topic. </span></div>
<p>Example</p>
<div class="p">The following example creates a
single container with these details.<ul><li>Name: <var class="keyword varname">my_container</var></li>
<li>Size: <var class="keyword varname">64 MB</var></li>
<li>Image: <var class="keyword varname">ibmliberty</var></li>
<li>Mounted volume: <var class="keyword varname">myvol</var></li>
<li>Exposed public port: <var class="keyword varname">9080</var></li>
<li>Bound IP address: <var class="keyword varname">192.0.2.23</var></li>
<li>Custom log file location: Standard Ubuntu log file. Logs from custom log file locations can be
viewed in Kibana after the container is created.</li>
</ul>
</div>
<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> run -p 192.0.2.23:9080:9080 -e <span class="q">"LOG_LOCATION=/var/log/dpkg.log"</span> -m 64 --name my_container --volume myvol:/var/tmp registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/ibmliberty </code></pre>
As the container is created, it is also started. The container is deployed when the ID for the
container is displayed.</li>
<li class="step stepexpand">Optional: <span class="cmd">List your running containers.*</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ps</code></pre>
</li>
</ol>
<div class="section postreq"><div class="p">If you are connecting to an external app from the container, there is up to a 5-minute
wait after you started the container process before it can connect to the specified IP address.
Then, you can verify that the app is functioning in the container by doing one of the following
options: <ul id="container_single_cli__d41675e375"><li>You can open the app in a browser by creating a URL with the public IP address and the port.
<p>Example</p>
<span class="ph filepath">http://<var class="keyword varname">public_IP</var>:<var class="keyword varname">public_port</var></span>
<div class="steps note"><span class="notetitle">Note:</span> If a service in the app exists that does not expose an HTTP endpoint, this option might not
display the app in the browser.</div>
</li>
<li>From the Linux or UNIX command line, you can run <span class="ph filepath">nc -zv
<var class="keyword varname"><public_IP></var>
<var class="keyword varname"><public_port></var></span> to verify that a server is listening on the port that
was specified.</li>
</ul>
</div>
<p>Next, if you are an organization manager you can view your organization's container billing.</p>
<div class="p"><ol><li>Click on the user avatar.</li>
<li>Click on <span class="ph uicontrol">Account</span>.</li>
<li>Expand your organization by clicking the <span class="ph uicontrol">+</span> button.</li>
<li>Select <span class="ph uicontrol">Usage Dashboard</span> and review the usage and billing details. </li>
</ol>
<span class="ph">For more information, go to <span class="ph"><a href="../billing-usage/manage_billing.html#viewbilling">Managing your account</a></span>.</span></div>
</div></div>
<aside role="complementary" aria-labelledby="d72924e728"></aside></article><article class="topic task nested1" role="article" aria-labelledby="d72924e1046" lang="en-us" id="container_single_updating"><h2 class="topictitle2" id="d72924e1046">Updating short-term tasks in single containers with the command line interface (CLI)</h2>
<div class="body taskbody"><p class="shortdesc">To update an app, you must deploy a new container. If you
push a new image, the container
is not restarted automatically.</p>
<div class="section context"><div class="tablenoborder"><table summary="" id="container_single_updating__updating_group_cli_table" class="defaultstyle"><caption><span class="tablecap">Table 2. Optional tools for updating an app</span></caption><thead><tr><th id="d72924e1111" class="thleft">Update tools</th>
<th id="d72924e1113" class="thleft">Description</th>
</tr>
</thead>
<tbody><tr><td headers="d72924e1111 "><span class="keyword">Delivery Pipeline</span></td>
<td headers="d72924e1113 ">Automate your app builds and container deployments to <span class="keyword">Cloud</span> by using the <span class="keyword">Delivery Pipeline</span>, which is a <span class="keyword">Cloud</span> service that is available to you. For
more information, see <a href="container_integrations.html#container_single_pipeline_ov" title="Automate the building and deploying of your single containers with the Delivery Pipeline.">Creating a single container by using the Delivery Pipeline</a>.</td>
</tr>
<tr><td headers="d72924e1111 ">UrbanCode Deploy</td>
<td headers="d72924e1113 ">Automate your app builds and container deployments to <span class="keyword">Cloud</span> by using UrbanCode Deploy. For more
information about purchasing UrbanCode Deploy, see the <a href="http://www.ibm.com/software/products/en/ucdep" rel="external" target="_blank" title="(Opens in a new tab or window)">IBM UrbanCode
Deploy</a> product page.</td>
</tr>
<tr><td headers="d72924e1111 ">Update the app yourself by using the <span class="keyword">IBM
Cloud Container Service</span> CLI</td>
<td headers="d72924e1113 ">Complete the steps in this task to update the app yourself.</td>
</tr>
</tbody>
</table>
</div>
</div><p class="li stepsection">To update a container yourself by using the <span class="keyword">IBM
Cloud Container Service</span> CLI:</p><ol class="steps"><li class="step stepexpand"><span class="cmd">Update the app locally.</span></li>
<li class="step stepexpand"><span class="cmd">Choose to either build your image directly in <span class="keyword">Cloud</span> or build and test your image locally
before you push it to <span class="keyword">Cloud</span>. </span> <ul><li>To build the image directly in <span class="keyword">Cloud</span>, run the following command.*<div class="note tip"><span class="tiptitle">Tip:</span> <span class="ph">Run <samp class="ph codeph"><span class="ph">bx ic</span> namespace-get</samp> to retrieve
your namespace and replace <var class="keyword varname"><my_namespace></var> with your namespace information.</span></div>
<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> build -t registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><my_namespace></var>/<var class="keyword varname"><image_name></var>:<var class="keyword varname"><tag></var> <var class="keyword varname"><dockerfile_location></var></code></pre>
Example<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> build -t registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname">my_namespace</var>/<var class="keyword varname">my_image</var>:<var class="keyword varname">v1</var> .</code></pre>
<div class="steps note"><span class="notetitle">Note:</span> <span class="ph" id="container_single_updating__d43200e229">*In this command, you can replace <samp class="ph codeph"><span class="ph">bx ic</span></samp> with <samp class="ph codeph">docker</samp>
when you <a href="container_cli_cfic_install.html#container_cli_login" title="After you install the CLI, log in to use it.">logged in to <span class="keyword">IBM
Cloud Container Service</span></a> and set your environment
variables to use native Docker commands.</span><span class="ph" id="container_single_updating__d43200e248">You can use native Docker
commands in all steps that are marked with an asterisk (*) in this topic. </span></div>
</li>
<li>To build the image locally and then push the image to <span class="keyword">Cloud</span>, follow these steps.<div class="p"><ol type="a"><li>If you are using the plug-in for <span class="keyword">IBM
Cloud Container Service</span>, log in again. Do not set the
environment variables for option 2, so that <samp class="ph codeph">docker</samp> commands will be sent to the
Docker engine on your local machine.<div class="p"><pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> init</code></pre>
</div>
</li>
<li>Build the image locally from your Dockerfile.<div class="p"><pre class="codeblock"><code>docker build -t <var class="keyword varname"><image_name></var>:<var class="keyword varname"><tag></var> <var class="keyword varname"><dockerfile_location></var></code></pre>
</div>
<div class="p">Example<pre class="codeblock"><code>docker build -t <var class="keyword varname">my_ibmliberty_image</var>:<var class="keyword varname">v1</var> .</code></pre>
</div>
</li>
<li>Run a container from the image to test that your new app runs locally by using the following
command, where <var class="keyword varname">Port</var> is the port for HTTP traffic.<div class="p"><pre class="codeblock"><code>docker run -d --name <var class="keyword varname"><container_name></var> <var class="keyword varname"><image_name></var></code></pre>
</div>
<div class="p">Example<pre class="codeblock"><code>docker run -d --name <var class="keyword varname">my_container</var> <var class="keyword varname">my_ibmliberty_image</var></code></pre>
</div>
<p>If
the app is running correctly, the container ID is displayed in the CLI output. To review the logs
for the container, run <samp class="ph codeph">docker logs
<var class="keyword varname"><container_name_or_id></var>.</samp></p>
</li>
<li id="container_single_updating__d43200e329">Tag the local image with your private <span class="keyword">Cloud</span> registry and a new name. <span class="ph">Use lowercase alphanumeric characters or underscores (_) only
in the image name. Other symbols, such as hyphens (-) or slashes (/), might prevent the image from
being pushed to the image registry.</span><div class="p"><pre class="codeblock"><code>docker tag <var class="keyword varname"><current_image_name_or_ID></var>:<var class="keyword varname"><optional_tag></var> registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><my_namespace></var>/<var class="keyword varname"><new_image_name></var>:<var class="keyword varname"><optional_tag></var> </code></pre>
</div>
<p>Example</p>
<div class="p"><pre class="codeblock"><code>docker tag <var class="keyword varname">my_ibmliberty_image</var> registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><my_namespace></var>/<var class="keyword varname">my_ibmliberty_image</var></code></pre>
</div>
</li>
<li>Push the image to your private <span class="keyword">Cloud</span> registry by using the following command.<div class="p"><pre class="codeblock"><code>docker push registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><my_namespace></var>/<var class="keyword varname"><image_name></var></code></pre>
</div>
<div class="p">Example<pre class="codeblock"><code>docker push registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname">my_namespace</var>/<var class="keyword varname">my_ibmliberty_image</var></code></pre>
</div>
</li>
</ol>
</div>
<div class="note important"><span class="importanttitle">Important:</span> <span class="ph">When you push an image to your private <span class="keyword">Cloud</span> registry, the size reported for the
image is smaller than the size of the same image in your local Docker engine. The difference between
the sizes does not indicate that an issue occurred when the image was pushed. The compressed size of
the image is reported in <span class="keyword">IBM
Cloud Container Service</span>.</span></div>
</li>
</ul>
</li>
<li class="step stepexpand"><span class="cmd">Unbind the public IP address from the container. </span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-unbind <var class="keyword varname"><public_IP_address></var> <var class="keyword varname"><container_name_or_id></var></code></pre>
<p>The container is no longer bound to the IP address, but the IP is still counted toward your
organization's public IP quota.</p>
</li>
<li class="step stepexpand"><span class="cmd">Verify that the IP address was unbound by running the following command.*</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> inspect <var class="keyword varname"><container_name_or_id></var></code></pre>
<p>If the value for <samp class="ph systemoutput">PublicIpAddress</samp> is not empty, wait a few minutes
longer and run the command again before you continue with the next step.</p>
</li>
<li class="step stepexpand"><span class="cmd">After the IP address was removed from the existing container, create another container with the
updated image.*</span> <pre class="codeblock"><code><span class="ph"><span class="ph"><samp class="ph codeph">bx ic</samp></span><span class="ph" id="container_single_updating__d43214e3572"> run [-p PORT] [-P] [-d] [-e ENV] [--env-file
ENVFILE] [-it] [--link NAME:ALIAS] [-m MEMORY] --name NAME [--volume VOLUME:/DIRECTORY_PATH] IMAGE [CMD [CMD ...]] </span></span></code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Bind the IP address to the new container.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-bind <var class="keyword varname"><public_IP_address></var> <var class="keyword varname"><container_name_or_id></var></code></pre>
</li>
<li class="step stepexpand">Optional: <span class="cmd">Delete the old container.*</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> rm <var class="keyword varname"><container_name_or_id></var></code></pre>
</li>
</ol>
</div>
<aside role="complementary" aria-labelledby="d72924e1046"></aside></article><article class="topic task nested1" role="article" aria-labelledby="d72924e1513" lang="en-us" id="container_linking"><h2 class="topictitle2" id="d72924e1513">Linking single containers with the command line interface (CLI)</h2>
<div class="body taskbody"><p class="shortdesc">When a container is linked to another container in the same space, <span class="keyword">IBM
Cloud Container Service</span> creates a host entry on the recipient
container for the source container. You can use an alias to refer to the source container, rather
than a specific IP address that might change frequently.</p>
<div class="section context"><p>Whenever you want a single container to communicate with another
container that is running an
image, such as <samp class="ph codeph">dbimage</samp>, you can address the container
by using an alias for the
host name, such as <samp class="ph codeph">dbserver</samp>. With this capability,
you can create a
<samp class="ph codeph">webserver</samp> image that refers to the database server
image by using the
<samp class="ph codeph">dbserver</samp> host name, regardless of what its IP address
or actual name is. You can
run many instances of the pair in the same image without having to
hand-off configuration or IP
information. You can always refer to the database server as <samp class="ph codeph">dbserver</samp>.</p>
</div><ol class="steps"><li class="step stepexpand"><span class="cmd">Create a source container by running the following command.*</span> <div class="note tip"><span class="tiptitle">Tip:</span> Make sure to include the <samp class="ph codeph">-p</samp> option to publish the port, which
exposes the port number to the recipient container. In a Dockerfile, the port that is exposed in the
image with the EXPOSE statement is not currently used by the linking run time.</div>
<div class="note tip"><span class="tiptitle">Tip:</span> <span class="ph">Run <samp class="ph codeph"><span class="ph">bx ic</span> namespace-get</samp> to retrieve
your namespace and replace <var class="keyword varname"><my_namespace></var> with your namespace information.</span></div>
<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> run -p <var class="keyword varname"><port></var> --name <var class="keyword varname"><source_container_name></var> registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><my_namespace></var>/<var class="keyword varname"><source_container_image_name></var> </code></pre>
Example
<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> run -p <var class="keyword varname">17546</var> --name <var class="keyword varname">source</var> registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><my_namespace></var>/<var class="keyword varname">dbimage</var> </code></pre>
<div class="steps note"><span class="notetitle">Note:</span> <span class="ph" id="container_linking__d36742e180">*In this command, you can replace <samp class="ph codeph"><span class="ph">bx ic</span></samp> with <samp class="ph codeph">docker</samp>
when you <a href="container_cli_cfic_install.html#container_cli_login" title="After you install the CLI, log in to use it.">logged in to <span class="keyword">IBM
Cloud Container Service</span></a> and set your environment
variables to use native Docker commands.</span><span class="ph" id="container_linking__d36742e192">You can use native Docker
commands in all steps that are marked with an asterisk (*) in this topic. </span></div>
</li>
<li class="step stepexpand"><span class="cmd">Create a recipient container and link it to the source container by running the following
command. *</span> For the alias, select a custom name for the image that is used in the source container. You
can expose multiple ports for the recipient container to the host container by including the
<span class="keyword option">-p</span> option multiple times. <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> run -p <var class="keyword varname"><port></var> -p <var class="keyword varname"><port></var> --name <var class="keyword varname"><recipient_container_name></var> --link <var class="keyword varname"><source_container_name></var>:<var class="keyword varname"><alias></var> registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><my_namespace></var>/<var class="keyword varname"><recipient_container_image_name></var> </code></pre>
Example<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> run -p 12534 -p 15256 --name <var class="keyword varname">recipient</var> --link <var class="keyword varname">source</var>:<var class="keyword varname">dbserver</var> registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><my_namespace></var>/<var class="keyword varname">webserver</var> </code></pre>
<p>The
container is linked when the ID for the recipient container is displayed.</p>
</li>
<li class="step stepexpand">Optional: <span class="cmd">Verify the environment variables that are injected by the link by logging into your container
using <samp class="ph codeph">exec</samp>.*</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> exec -it <var class="keyword varname"><recipient_container_name></var> bash </code></pre>
<div class="p">Run the <samp class="ph codeph">env</samp> command in the bash window to see the details of the
alias.<pre class="codeblock"><code>"Env": [
"<var class="keyword varname"><alias></var>_PORT_<source_container_port>/tcp_TCP_PORT=<source_container_port>/tcp",
"<var class="keyword varname"><alias></var>_PORT_<source_container_port>/tcp_TCP=tcp://<var class="keyword varname"><recipient_container_private_IP></var>:<source_container_port>/tcp",
"<var class="keyword varname"><alias></var>_ENV_space_id=<var class="keyword varname"><space_ID></var>",
"logging_password=",
"space_id=<var class="keyword varname"><space_ID></var>",
"logstash_target=logs.opvis.bluemix.net:9091",
"<var class="keyword varname"><alias></var>_PORT_<var class="keyword varname"><source_container_port></var>/tcp_TCP_ADDR=<var class="keyword varname"><recipient_container_private_ip></var>",
"<var class="keyword varname"><alias></var>_ENV_metrics_target=metrics.opvis.bluemix.net:9095",
"<var class="keyword varname"><alias></var>_NAME=/<var class="keyword varname"><recipient_container></var>/<var class="keyword varname"><alias></var>",
"<var class="keyword varname"><alias></var>_ENV_logstash_target=logs.opvis.bluemix.net:9091",
"<var class="keyword varname"><alias></var>_ENV_logging_password=",
"<var class="keyword varname"><alias></var>_PORT_<var class="keyword varname"><source_container_port></var>/tcp_TCP_PROTO=tcp",
"metrics_target=metrics.opvis.bluemix.net:9095"
],</code></pre>
</div>
</li>
</ol>
</div>
<aside role="complementary" aria-labelledby="d72924e1513"></aside></article><article class="topic task nested1" role="article" aria-labelledby="d72924e1825" lang="en-us" id="container_cli_ips"><h2 class="topictitle2" id="d72924e1825">Requesting and binding public IP addresses to containers</h2>
<div class="body taskbody"><p class="shortdesc">Request and bind a public IP address to a container in <span class="keyword">Cloud</span>.</p>
<div class="section prereq"><div class="steps note"><span class="notetitle">Note:</span> Binding a public IP address does not include a SSL certificate which encrypts the
data that are sent to and from your single container. If your app requires SSL encryption, you can
either implement your own SSL solution or use a container group instead of a single container.
Container groups are bound to a public route that already includes a SSL certificate, so you can
access your container group with HTTPS without any additional configuration. For more information,
see <a href="container_ha.html#container_group_ui" title="Create and deploy a scalable group container from the Cloud GUI. A container group includes two or more containers that run the same image. Use container groups for running long-term services with workloads that require scalability and reliability or for testing at the required scale.">Creating a container group with the
GUI</a>.</div>
<p>Before you begin, to check whether a public IP address exists for the space that you can use
instead of creating one, see <a href="container_single_ui.html#container_cli_ips_list" title="To make single containers accessible from the Internet, you must bind a public IP address to it. Before you request an IP address, review the list of public IP addresses already assigned to your organization and see whether one of those existing IP addresses are available.">Finding existing public IP addresses for your organization with the command line interface (CLI)</a>.</p>
</div><ol class="steps"><li class="step stepexpand"><span class="cmd">Request a public IP address.</span> When requesting a public IP address, a random one from the public IP address pool is
allocated to the space. While allocated to a space, the IP address does not change.
<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-request</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Note the IP address.</span></li>
<li class="step stepexpand"><span class="cmd">Bind the address to a new container or an existing running
container.</span> <ul class="ul choices"><li class="li choice">To bind to an existing running
container<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-bind <var class="keyword varname"><public_IP_address></var> <var class="keyword varname"><container_name_or_id></var></code></pre>
Example<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-bind 192.0.2.23 my_container</code></pre>
</li>
<li class="li choice">To bind to a new
container<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> run -p <var class="keyword varname"><ip-address></var>:<var class="keyword varname"><container-port></var>:<var class="keyword varname"><container-port></var> --name <var class="keyword varname"><container_name></var> registry.<span class="keyword" data-hd-keyref="DomainName">DomainName</span>/<var class="keyword varname"><my_namespace></var>/<var class="keyword varname"><image_name></var></code></pre>
</li>
</ul>
</li>
</ol>
<div class="section result">The bind request is made immediately, but the connectivity to the container with the IP
address might take a few minutes.</div></div>
<aside role="complementary" aria-labelledby="d72924e1825"></aside><article class="topic task nested2" role="article" aria-labelledby="d72924e1976" lang="en-us" id="container_cli_ips_list"><h3 class="topictitle3" id="d72924e1976">Finding existing public IP addresses for your organization with the command line interface
(CLI)</h3>
<div class="body taskbody"><p class="shortdesc">To make single containers accessible from the Internet, you must bind a public IP address
to it. Before you request an IP address, review the list of public IP addresses already assigned to
your organization and see whether one of those existing IP addresses are available.</p>
<div class="section context"><div class="steps note"><span class="notetitle">Note:</span> Binding a public IP address does not include a SSL certificate which encrypts the
data that are sent to and from your single container. If your app requires SSL encryption, you can
either implement your own SSL solution or use a container group instead of a single container.
Container groups are bound to a public route that already includes a SSL certificate, so you can
access your container group with HTTPS without any additional configuration. For more information,
see <a href="container_ha.html#container_group_ui" title="Create and deploy a scalable group container from the Cloud GUI. A container group includes two or more containers that run the same image. Use container groups for running long-term services with workloads that require scalability and reliability or for testing at the required scale.">Creating a container group with the
GUI</a>.</div>
</div><div class="step"><span class="cmd">List available public IP addresses for your space.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ips</code></pre>
</div>
<div class="section postreq">If you do not have any IP addresses or want to request one, you can choose between the
following options. You can request one either when you create a single container by using the
<span class="keyword">Cloud</span> GUI or when you run <samp class="ph codeph"><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-request</samp> from the command line. To
request an IP address by using the command line, see <a href="container_single_ui.html#container_cli_ips" title="Request and bind a public IP address to a container in Cloud.">Requesting and binding public IP addresses to containers</a>.</div></div>
<aside role="complementary" aria-labelledby="d72924e1976"></aside></article><article class="topic task nested2" role="article" aria-labelledby="d72924e2077" lang="en-us" id="container_cli_ips_unbind"><h3 class="topictitle3" id="d72924e2077">Unbinding public IP addresses from a container</h3>
<div class="body taskbody"><p class="shortdesc">You can unbind a public IP address from a container, but the IP address is still
available to other containers and counted toward your organization's public IP quota. </p>
<ol class="steps"><li class="step stepexpand" id="container_cli_ips_unbind__unbind"><span class="cmd">Unbind the public IP address from the container. </span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-unbind <var class="keyword varname"><public_IP_address></var> <var class="keyword varname"><container_name_or_id></var></code></pre>
<p>The container is no longer bound to the IP address, but the IP is still counted toward your
organization's public IP quota.</p>
</li>
<li class="step stepexpand"><span class="cmd">Verify that the IP address is successfully unbound. </span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ips</code></pre>
</li>
</ol>
</div>
<aside role="complementary" aria-labelledby="d72924e2077"></aside></article><article class="topic task nested2" role="article" aria-labelledby="d72924e2159" lang="en-us" id="container_cli_ips_remove"><h3 class="topictitle3" id="d72924e2159">Removing public IP addresses from your quota</h3>
<div class="body taskbody"><p class="shortdesc">If you are not using a public IP address or must delete one to request a new one, you can
remove a public IP address from your organization's quota. </p>
<div class="section prereq">Before you begin, unbind the public IP address from any containers that are using
it.</div><ol class="steps"><li class="step stepexpand"><span class="cmd">Remove the IP address from your organization's quota.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-release <var class="keyword varname"><public_IP_address></var> </code></pre>
</li>
<li class="step stepexpand">Optional: <span class="cmd">Verify that the IP address is not listed as allocated anymore. </span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ips</code></pre>
</li>
</ol>
</div>
<aside role="complementary" aria-labelledby="d72924e2159"></aside></article></article><article class="topic task nested1" role="article" aria-labelledby="d72924e2239" lang="en-us" id="container_single_remove"><h2 class="topictitle2" id="d72924e2239">Removing single containers</h2>
<div class="body taskbody"><p class="shortdesc">To maximize the use of your quota, remove containers that are not in use
occasionally.</p>
<ol class="steps"><li class="step stepexpand"><span class="cmd">Remove a container by using one of the following methods.</span> <ul class="ul choices"><li class="li choice">From the <span class="keyword">Cloud</span> GUI<ol type="a"><li>From the <span class="keyword">Cloud</span> Dashboard, select
the container that you want to delete.</li>
<li>Expand the <span class="ph uicontrol">More actions...</span> menu and click
<span class="ph uicontrol">Delete</span>.</li>
</ol>
<ul><li>In the tile for the container, click the gear icon and click <span class="ph uicontrol">Delete
container</span>. </li>
</ul>
</li>
<li class="li choice">From the CLI
*<pre class="codeblock"><code><span class="ph"><span class="ph"><samp class="ph codeph">bx ic</samp></span> rm [-f] CONTAINER [CONTAINER] </span></code></pre>
<div class="steps note"><span class="notetitle">Note:</span> <span class="ph" id="container_single_remove__d42497e180">*In this command, you can replace <samp class="ph codeph"><span class="ph">bx ic</span></samp> with <samp class="ph codeph">docker</samp>
when you <a href="container_cli_cfic_install.html#container_cli_login" title="After you install the CLI, log in to use it.">logged in to <span class="keyword">IBM
Cloud Container Service</span></a> and set your environment
variables to use native Docker commands.</span><span class="ph" id="container_single_remove__d42497e192">You can use native Docker
commands in all steps that are marked with an asterisk (*) in this topic. </span></div>
</li>
</ul>
</li>
<li class="step stepexpand">Optional: <span class="cmd">Verify that the container was removed by running the following command and confirming that the
container does not appear in the list.*</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ps -a</code></pre>
</li>
</ol>
</div>
<aside role="complementary" aria-labelledby="d72924e2239"></aside></article><article class="topic tutorial nested1" role="article" aria-labelledby="d72924e2390" lang="en-us" id="container_gettingstarted_tutorial"><h2 class="topictitle2" id="d72924e2390">Tutorial: Creating a single container web application</h2>
<div class="body tutorialBody"><p class="shortdesc"><span class="keyword">IBM
Cloud</span> gives you the ability to
run Docker containers in the public cloud. Use containers to deploy self-contained, secure web apps
that run independently of the host operating system. Containers are lightweight and do not require a
lot of system resources because containers use the same system kernel and so can be run more
efficiently than a virtual machine. This tutorial showcases how to build a messaging web app using
Docker containers in <span class="keyword">Cloud</span>.
In the process, you will write a Dockerfile, add Docker images to your private <span class="keyword">Cloud</span> images registry and link
containers together.</p>
<div class="section tutorialDesc"></div><section class="section learningObjectives tutorialLearningObjectives" role="region" aria-labelledby="d72924e2456"><h3 class="sectiontitle" id="d72924e2456">Objectives</h3>
<p>In this scenario you will create a web app called Let's Chat in your <span class="keyword">Cloud</span> space. Let's Chat is an online messaging
app designed for small development teams. Using <span class="keyword">Cloud</span>, you can manage a private Docker images
registry and deploy your web app to be publicly accessible.</p>
<figure class="fignone" id="container_gettingstarted_tutorial__getting_started_tutorial"><figcaption>Figure 1. Architecture of your running web app</figcaption><div class="image"><object width="480" data="images/getting_started_tutorial.svg"><img width="480" src="images/getting_started_tutorial.jpg" alt="Lets Chat tutorial diagram"></object></div></figure>
<div class="p">This scenario provides instructions for the following tasks:<ul><li>Setting up a <span class="keyword">Cloud</span> account</li>
<li>Setting up the <span class="keyword">IBM
Cloud Container Service</span> command-line
interface</li>
<li>Creating a Dockerfile</li>
<li>Pushing an image to your private <span class="keyword">Cloud</span> images registry</li>
<li>Linking two containers, which creates a network connection between containers</li>
<li>Building a container that can be accessed by the public </li>
</ul>
</div>
</section>
<section class="section timeRequired tutorialTimeRequired" role="region" aria-labelledby="d72924e2509"><h3 class="sectiontitle" id="d72924e2509">Time required</h3>45 minutes</section>
<section role="region" aria-labelledby="d72924e2513"><h3 class="sectiontitle" id="d72924e2513">Audience</h3>
<p>This tutorial is intended for users who are new to Docker containers in <span class="keyword">Cloud</span> and want to learn how to
deploy a running app in the <span class="keyword">Cloud</span> public cloud.</p>
</section></div>
<article class="topic task tutorialLesson nested2" role="article" aria-labelledby="d72924e2527" lang="en-us" id="container_gettingstarted_tutorial_lesson_1"><h3 class="topictitle3" id="d72924e2527">Lesson 1: Setting up <span class="keyword">IBM
Cloud Container Service</span></h3>
<div class="body taskbody"><p class="shortdesc">In this lesson, you will create your <span class="keyword">Cloud</span> account, install the <span class="keyword">IBM
Cloud Container Service</span> CLI, log in to your account and review
the default IBM images. </p>
<ol class="steps"><li class="step stepexpand"><span class="cmd">Go to the <a href="https://console.ng.bluemix.net/registration/" rel="external" target="_blank" title="(Opens in a new tab or window)"><span class="keyword">Cloud</span> registration
page</a> to create an account.</span> Make note of your user name and password as this information is required later.</li>
<li class="step stepexpand"><span class="cmd">Install Cloud Foundry CLI version <span class="ph">Cloud Foundry CLI version <span class="ph" id="container_gettingstarted_tutorial_lesson_1__d28262e281">6.14.0</span> - 6.22.0</span>
from the <a href="https://github.com/cloudfoundry/cli/releases" rel="external" target="_blank" title="(Opens in a new tab or window)">GitHub repository</a>.</span> You must install the Cloud Foundry CLI in the default location for your operating system,
otherwise the PATH environment variable does not match your installation directory. <div class="steps note"><span class="notetitle">Note:</span> MacOS Sierra users must install Cloud Foundry CLI version 6.22.0 or later. </div>
<div class="p">To verify that the Cloud Foundry CLI is installed properly or, if you already installed the Cloud
Foundry CLI, to check which version you installed, run the following
command:<pre class="codeblock"><code>cf -v</code></pre>
</div>
</li>
<li class="step stepexpand"><span class="cmd"><a href="https://www.docker.com/products/docker" rel="external" target="_blank" title="(Opens in a new tab or window)">Install
Docker 1.10.0 or later</a> from the Docker website.</span></li>
<li class="step stepexpand"><span class="cmd">Open your Docker terminal.</span> If you are using the Docker Toolbox for Windows or OS X, open a program called Docker
Quickstart Terminal. </li>
<li class="step stepexpand"><span class="cmd">Install the <a href="https://clis.ng.bluemix.net/ui/home.html" rel="external" target="_blank" title="(Opens in a new tab or window)"><span class="keyword">Cloud</span>
CLI</a>.</span></li>
<li class="step stepexpand"><span class="cmd" id="container_gettingstarted_tutorial_lesson_1__d28262e320">Install the <span class="keyword">IBM
Cloud Container Service</span> plug-in. </span> <pre class="codeblock" id="container_gettingstarted_tutorial_lesson_1__d28262e331"><code><span class="ph">bx</span> plugin install IBM-Containers -r <span class="ph" data-hd-audience="yellow"><var class="keyword varname">Bluemix</var></span></code></pre>
<div class="p">To verify that the plug-in is installed properly, run the following
command:<pre class="codeblock"><code><span class="ph">bx</span> plugin list</code></pre>
</div>
<p>The plug-in is displayed in the results as IBM-Containers.</p>
</li>
<li class="step stepexpand"><span class="cmd">Now that you have the <span class="keyword">IBM
Cloud Container Service</span>
plug-in installed, run <samp class="ph codeph">docker run hello-world</samp> in your Docker terminal. </span> <pre class="codeblock"><code>docker run hello-world</code></pre>
This verifies that your Docker configuration is set up correctly. Docker looks for the local
image, so if this is your first time running the command you will see the following message:
<pre class="pre screen"><code>Unable to find image 'hello-world:latest' locally</code></pre>
The image is pulled from Docker
Hub, a public repository of images, and after the command completes, your output looks like the
following:<pre class="pre screen"><code>$ docker run hello-world
Hello from Docker.
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the <span class="q">"hello-world"</span> image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/userguide/</code></pre>
If hello-world does not execute, run <samp class="ph codeph">docker version</samp> to identify that Docker
is installed correctly. Windows and OS X users, confirm you are running Docker Quickstart Terminal
and not your standard terminal window.</li>
<li class="step stepexpand">Optional: <span class="cmd">If this is your first time using <span class="keyword">Cloud</span>, specify an API endpoint. The following
code sample defaults to the region of your <span class="keyword">Cloud</span> account, but you can change regions
manually. </span> <pre class="codeblock"><code>bx api https://api.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var></code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Now log in to your <span class="keyword">Cloud</span>
account.</span> Enter the email and password that you specified when you were creating your <span class="keyword">Cloud</span> account. If needed, select your
preferred organization and space at the prompts.<pre class="codeblock"><code>bx login [-sso]</code></pre>
<span class="ph">The single-sign-on parameter <span class="keyword option">--sso</span> is required when you log in
with a federated ID. If this option is used, open <a href="https://login.ng.bluemix.net/UAALoginServerWAR/passcode" rel="external" target="_blank" title="(Opens in a new tab or window)">https://login.ng.bluemix.net/UAALoginServerWAR/passcode</a> to obtain a one-time passcode. If
you do not include the <span class="keyword option">--sso</span> option, complete these substeps.</span><ol type="a" class="ol substeps"><li class="li substep"><span class="cmd">For <span class="ph uicontrol">Email</span>, enter your IBMId for
<span class="keyword">Cloud</span>.</span></li>
<li class="li substep"><span class="cmd">For <span class="ph uicontrol">Password</span>, enter the password for the IBMId.</span> Your <span class="keyword">Cloud</span> organizations and
spaces are retrieved. </li>
<li class="li substep"><span class="cmd">Enter the number that represents one of your <span class="keyword">Cloud</span> organizations. </span></li>
<li class="li substep"><span class="cmd">Enter the number that represents one of your existing <span class="keyword">Cloud</span> spaces. </span></li>
</ol>
</li>
<li class="step stepexpand"><span class="cmd">Create a namespace. </span> Your organization's namespace is a unique identifier for your registry of container images in
a <span class="keyword">Cloud</span> region. Think of the
namespace as a way of distinguishing your <span class="keyword">Cloud</span> images registry from every other image
registry in the IBM public cloud.<div class="steps note"><span class="notetitle">Note:</span> If you or any other user has logged in to your <span class="keyword">Cloud</span> organization and created
containers, you already have a namespace. You can find out its value by running the following
command:<pre class="codeblock"><code><samp class="ph codeph"><span class="ph">bx ic</span> namespace-get</samp></code></pre>
</div>
<div class="p">Here are a few tips for creating your namespace:<ul><li>Your namespace must be unique. It cannot be used by any other organization in the same region of
the IBM public cloud.</li>
<li>Your namespace can be 4-30 characters and can contain lowercase letters, numbers, or underscores
(_) only.</li>
<li>Keep your namespace short. If you use the command line, you will type the namespace frequently
as part of tagging and pushing your images.</li>
</ul>
</div>
<p>In the following command, replace <var class="keyword varname">your_registry_name_here</var> with the namespace
that you choose:</p>
<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> namespace-set <var class="keyword varname">your_registry_name_here</var></code></pre>
</li>
<li class="step stepexpand">Optional: <span class="cmd">Set a variable for your namespace.</span> Throughout this tutorial, example commands will include the <samp class="ph codeph">$your_namespace</samp>
string to show where to place your namespace. To avoid editing those commands manually, create a
variable in your terminal. <pre class="codeblock"><code>your_namespace=<var class="keyword varname">your_registry_name_here</var></code></pre>
Example using <samp class="ph codeph">ljenkins1</samp> as the user's namespace <pre class="pre screen"><code>$ your_namespace=<var class="keyword varname">ljenkins1</var></code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Initialize <span class="keyword">IBM
Cloud Container Service</span>.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> init</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Now that you have logged in to<span class="keyword">IBM
Cloud Container Service</span>, let's check out the default images that
are available to you. </span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> images</code></pre>
<pre class="pre screen"><code>$ <span class="ph"><samp class="ph codeph">bx ic</samp></span> images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.ng.bluemix.net/ibm-mobilefirst-starter latest d61c09fd0af7 4 weeks ago 510.2 MB
registry.ng.bluemix.net/ibm-node-strong-pm latest 322b9ca7b2dc 2 weeks ago 255.5 MB
registry.ng.bluemix.net/ibmliberty latest 33fdda9431c7 2 days ago 292.5 MB
registry.ng.bluemix.net/ibmnode latest c33c25d4af3b 2 days ago 187.8 MB
registry.ng.bluemix.net/ibmnode v4 c33c25d4af3b 2 days ago 187.8 MB
registry.ng.bluemix.net/ibmnode v1.1 ef3425f90e1e 2 days ago 175.3 MB
registry.ng.bluemix.net/ibmnode v1.2 c5546bf5e891 2 days ago 183.6 MB</code></pre>
<div class="tablenoborder"><table summary="" id="container_gettingstarted_tutorial_lesson_1__table_lqp_hkm_2v" class="defaultstyle"><caption><span class="tablecap">Table 3. Learn more about images and containers</span></caption><thead><tr><th colspan="2" id="d72924e2921" class="thleft"><span class="ph"><img src="images/idea.png" alt="This icon indicates there is more information to learn about this step of the task."></span> More about
images and containers</th>
</tr>
</thead>
<tbody><tr><td style="width: NaN%" headers="d72924e2921 ">Image vs. Container</td>
<td style="width: NaN%" headers="d72924e2921 "><p> So, what is the difference between an image and a container? Essentially, an image is a
read-only snapshot of defined layers and commands. Only after you run the image does it become a
container. One of the benefits of this process is that no matter what changes you make to a
container, an image snapshot remains unchanged. Single containers are, by design, meant to temporary
processes. Configurations or data that needs to be persisted across containers must be written into
the image or stored in a persistent volume. See the Docker Glossary for a <a href="https://docs.docker.com/glossary/?term=image" rel="external" target="_blank" title="(Opens in a new tab or window)">definition of
image</a>.</p>
</td>
</tr>
<tr><td style="width: NaN%" headers="d72924e2921 ">IBM Images</td>
<td style="width: NaN%" headers="d72924e2921 "><p>In this tutorial, you are using images from Docker Hub. However, IBM also provides four of those
image <span class="q">"snapshots"</span> that you can use to build your own images or that you can use to run a
container. Read about the <a href="container_images_adding_ov.html" title="A container image is the basis for every container that you create. An image is created from a Dockerfile, which is a file that contains instructions to build the image, and build artifacts, such as an app, the app's configuration, and its dependencies. Think of a container image as an executable file (.exe or .bin). As soon as you run the executable app file, you create an instance of your app. When you run a container, you create a container instance from the image.">IBM images</a> here.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li>
</ol>
<div class="section result"><p>Congratulations! You have successfully created your account, installed the CLI plug-ins and have
logged in to see the images that are available to you for building your web apps.</p>
<p>To add images to your registry, continue to the next lesson.</p>
</div></div>
</article><article class="topic task tutorialLesson nested2" role="article" aria-labelledby="d72924e2964" lang="en-us" id="container_gettingstarted_tutorial_lesson_2"><h3 class="topictitle3" id="d72924e2964">Lesson 2: Adding images to your private <span class="keyword">Cloud</span> images registry</h3>
<div class="body taskbody"><p class="shortdesc">In this lesson you use two methods to add images to your private images registry: copying
an image from Docker Hub and creating a Dockerfile. Creating your own Dockerfile allows you to add
your own commands to an image. Thus, every container launched from that image contains those
commands. One of the benefits of containers is that these images help you maintain source control so
that everyone in your organization can build containers with a consistent operating
environment.</p>
<div class="section context">The following images are used in this lesson. You can review the Dockerfiles for the images
and other information in Docker Hub.<ul><li><a href="https://hub.docker.com/_/mongo/" rel="external" target="_blank" title="(Opens in a new tab or window)">MongoDB</a></li>
<li><a href="https://hub.docker.com/r/sdelements/lets-chat/" rel="external" target="_blank" title="(Opens in a new tab or window)">Let's
Chat</a></li>
</ul>
</div><ol class="steps"><li class="step stepexpand"><span class="cmd">Copy the MongoDB image from Docker Hub to your private <span class="keyword">Cloud</span> images registry.</span> The MongoDB image is used to store data. Even though the MongoDB container can be used to
store data, any data written to the container is lost when the container is removed. To persist any
data that is written to a container, you must mount a volume when you run a container. <p>Remember to replace <samp class="ph codeph"><var class="keyword varname">$your_namespace</var></samp> with the namespace that
you created in Lesson 1 if you did not set up the variable replacement. If you need to confirm what
your namespace is, run <samp class="ph codeph"><span class="ph"><samp class="ph codeph">bx ic</samp></span> namespace
get</samp>.</p>
<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> cpi <var class="keyword varname">mongo</var> registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var></code></pre>
The initial output code will be similar to this
example.<pre class="pre screen"><code>$ <span class="ph"><samp class="ph codeph">bx ic</samp></span> cpi mongo registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var>
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM mongo
---> 32427ae49eff
Successfully built 32427ae49eff
The push refers to a repository [registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var>] (len: 1)</code></pre>
In the background, the mongo image from Docker Hub is being copied to your images registry.
The <samp class="ph codeph">cpi</samp> command can take a few minutes to complete, and when it does complete the
full output will look like the following
example.<pre class="pre screen"><code>$ <span class="ph"><samp class="ph codeph">bx ic</samp></span> cpi mongo registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var>
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM mongo
---> 32427ae49eff
Successfully built 32427ae49eff
The push refers to a repository [registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var>] (len: 1)
32427ae49eff: Pushed
424ec4bd7fc4: Pushed
9e3490ec0722: Pushed
166aa7bca9c1: Pushed
c79deeebd6f0: Pushed
c181e50c0e8b: Pushed
438e27bd44bf: Pushed
af6f43fa45bb: Pushed
605e5767a4ac: Pushed
33e8076f6b28: Pushed
e63969171eec: Pushed
latest: digest: sha256:ab092d78d331337cf6cf0ceeda28489f5e154b1403ca1220e9de6b417
b7cfb95 size: 32158</code></pre>
<div class="tablenoborder"><table summary="" id="container_gettingstarted_tutorial_lesson_2__table_sdf_nkm_2v" class="defaultstyle"><thead><tr><th colspan="2" id="d72924e3131" class="thleft"><span class="ph"><img src="images/idea.png" alt="This icon indicates there is more information to learn about this step of the task."></span> Understanding
this command's components</th>
</tr>
</thead>
<tbody><tr><td style="width: NaN%" headers="d72924e3131 "><samp class="ph codeph">cpi</samp></td>
<td style="width: NaN%" headers="d72924e3131 ">The copy command.</td>
</tr>
<tr><td style="width: NaN%" headers="d72924e3131 "><samp class="ph codeph">mongo</samp></td>
<td style="width: NaN%" headers="d72924e3131 ">The source repository and name. In this case, the name of the image is
<var class="keyword varname">mongo</var> and no further repository definition is needed since the image is located
in Docker Hub.</td>
</tr>
<tr><td style="width: NaN%" headers="d72924e3131 "><samp class="ph codeph">registry. <var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>
/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var></samp></td>
<td style="width: NaN%" headers="d72924e3131 ">The destination registry path, which includes your unique namespace and the name of the
destination image. For this example, we are keeping the name of the image as
<var class="keyword varname">mongo</var>, but you can choose any name for images in your private registry. When
working with this image in the CLI, you specify the image by the full path:
<samp class="ph codeph">registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var></samp></td>
</tr>
</tbody>
</table>
</div>
</li>
<li class="step stepexpand"><span class="cmd">Create and navigate to a new local folder for your Dockerfile.</span> Now that you have added an image to your registry via the <samp class="ph codeph">cpi</samp> command, you
are going to create another image from a Dockerfile. A Dockerfile allows you to build an image
locally and allows you to add any additional commands or variables needed for your web app. Some of
these commands can be added during the container build, but this can create fragmentation with
multiple versions of the same image. Adding commands to the Dockerfile ensures that every container
that is built from this image has these commands. <pre class="codeblock"><code>mkdir wrapper && cd wrapper</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Create a Dockerfile within the <span class="ph filepath">wrapper</span> folder.</span> This command creates a Dockerfile and adds the specified <var class="keyword varname">FROM</var> command,
which is required in all Dockerfiles. <var class="keyword varname">FROM</var> states what the parent image will be.
In this case, we are using the <var class="keyword varname">lets-chat</var> image as our parent. <pre class="codeblock"><code>echo <span class="q">"FROM sdelements/lets-chat:latest"</span> > Dockerfile</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Confirm the Dockerfile was created by listing files in your current directory.</span> <pre class="codeblock"><code>ls</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Add a network delay command to your Dockerfile.</span> When the lets-chat container starts, <span class="keyword">IBM
Cloud Container Service</span> sets up the private container network
and assigns a private IP address to the container. The lets-chat app requires an active network
connection at the time the app starts. Adding the network delay ensures that there is enough time
for the <span class="keyword">IBM
Cloud Container Service</span> networking to finish
before the app is started. <pre class="codeblock"><code>echo <span class="q">"CMD (sleep 60; npm start)"</span> >> Dockerfile</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Build and tag your image.</span> Don't forget the <samp class="ph codeph">.</samp> at the end of the command! The period tells Docker to look
inside your current local folder for the needed Dockerfile. <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> build -t registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/lets-chat .</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Confirm that your <var class="keyword varname">mongo</var> image and your <var class="keyword varname">lets-chat</var> image
are in your <span class="keyword">Cloud</span> images
registry.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> images</code></pre>
<pre class="pre screen"><code>$ <span class="ph"><samp class="ph codeph">bx ic</samp></span> images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var> latest 8de059ee71fc 2 minutes ago 317.4 MB
registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">lets-chat </var> latest d4de00f58363 5 minutes ago 0 B
registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/ibm-node-strong-pm latest 322b9ca7b2dc 2 weeks ago 616.4 MB
registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/ibmliberty latest 6595ea483bf5 2 weeks ago 552.8 MB
registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/ibmnode latest b2c351248227 2 weeks ago 472.4 MB
registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/ibmnode v4 b2c351248227 2 weeks ago 472.4 MB
registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/ibmnode v1.1 7d11220193d6 2 weeks ago 449.2 MB
registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/ibmnode v1.2 84efce0c747b 2 weeks ago 465.2 MB</code></pre>
</li>
</ol>
<div class="section result"><p>Now the necessary images are in your private <span class="keyword">Cloud</span> images registry! You successfully copied
a Docker Hub image, as well as created a Dockerfile, built a new image and pushed that image into
your <span class="keyword">Cloud</span> images registry.</p>
<p>In the next lesson you get to create the containers, link them together and deploy your web
app.</p>
</div></div>
</article><article class="topic task tutorialLesson nested2" role="article" aria-labelledby="d72924e3344" lang="en-us" id="container_gettingstarted_tutorial_lesson_3"><h3 class="topictitle3" id="d72924e3344">Lesson 3: Building and deploying containers</h3>
<div class="body taskbody"><p class="shortdesc">You have the necessary images in your <span class="keyword">Cloud</span> images registry to deploy the Let's Chat
messaging web app. In this lesson, you will build the containers, link them together and assign a
public IP address to the app.</p>
<ol class="steps"><li class="step stepexpand"><span class="cmd">Run your container from the mongo image.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> run --name <var class="keyword varname">lc-mongo</var> -p <var class="keyword varname">27017</var> -m <var class="keyword varname">128</var> registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/mongo</code></pre>
<div class="tablenoborder"><table summary="" id="container_gettingstarted_tutorial_lesson_3__table_lqp_hkm_2v" class="defaultstyle"><thead><tr><th colspan="2" id="d72924e3430" class="thleft"><span class="ph"><img src="images/idea.png" alt="This icon indicates there is more information to learn about this step of the task."></span> Understanding
this command's components</th>
</tr>
</thead>
<tbody><tr><td style="width: 22.22222222222222%" headers="d72924e3430 ">run</td>
<td style="width: 77.77777777777779%" headers="d72924e3430 "><p> The run command that creates the container from the specified image.</p>
</td>
</tr>
<tr><td style="width: 22.22222222222222%" headers="d72924e3430 ">--name</td>
<td style="width: 77.77777777777779%" headers="d72924e3430 ">Defines the name of the container. In this case, we named the container
<var class="keyword varname">lc-mongo</var>.</td>
</tr>
<tr><td style="width: 22.22222222222222%" headers="d72924e3430 ">-p</td>
<td style="width: 77.77777777777779%" headers="d72924e3430 "><span class="ph">If you want to make your app accessible from the Internet, you must
expose a public port. When you expose a public port, you create a Public Network Security Group for
your container that allows you to send and receive public data on the exposed port only. All other
public ports are closed and cannot be used to access your app from the internet. You can include
multiple ports with multiple <span class="keyword option">-p</span> options. Ports cannot be mapped or forwarded. If
you do not expose a port, your container is accessible from the private container network only. You
can use the assigned private IP address to communicate with your container on the private network.</span> In
this case, we are exposing port 27017 since that port was specified in the Dockerfile. </td>
</tr>
<tr><td style="width: 22.22222222222222%" headers="d72924e3430 ">-m</td>
<td style="width: 77.77777777777779%" headers="d72924e3430 "><span class="ph">Enter a memory limit for your container in MB. The memory limit
is part of the container size that defines the maximum amount of memory and disk space a container
gets on the compute host during runtime. After a container size is assigned, the value cannot be
changed.</span></td>
</tr>
</tbody>
</table>
</div>
</li>
<li class="step stepexpand"><span class="cmd">Confirm that the container is running.</span> Wait for the status to update to running before continuing to the next step. If needed, you
can run <samp class="ph codeph"><span class="ph"><samp class="ph codeph">bx ic</samp></span> ps</samp> until the
container status is running. <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ps</code></pre>
<pre class="pre screen"><code>$<span class="ph"><samp class="ph codeph">bx ic</samp></span> ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f73abc2-9a1 registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var>:latest <span class="q">""</span> 40 seconds ago Running 5 seconds ago 27017/tcp lc-mongo</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">After your <var class="keyword varname">mongo</var> container is running, run your <var class="keyword varname">lets-chat</var>
container.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> run --name <var class="keyword varname">lets-chat</var> --link lc-mongo:mongo -p <var class="keyword varname">8080</var> -m <var class="keyword varname">128</var> registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">lets-chat</var></code></pre>
<div class="tablenoborder"><table summary="" id="container_gettingstarted_tutorial_lesson_3__table_o22_ttv_4x" class="defaultstyle"><thead><tr><th colspan="2" id="d72924e3540" class="thleft"><span class="ph"><img src="images/idea.png" alt="This icon indicates there is more information to learn about this step of the task."></span> Understanding
this command's components</th>
</tr>
</thead>
<tbody><tr><td style="width: 22.22222222222222%" headers="d72924e3540 ">--link</td>
<td style="width: 77.77777777777779%" headers="d72924e3540 "><p>Linking a database container like <samp class="ph codeph">lc-mongo</samp> to another container is one of the
common uses of <samp class="ph codeph">--link</samp>. The <samp class="ph codeph">--link</samp> flag creates a host entry on the
<var class="keyword varname">lets-chat</var> container for the <var class="keyword varname">lc-mongo</var> container, which allows
the containers to communicate with one another.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li>
<li class="step stepexpand"><span class="cmd">View your containers.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ps</code></pre>
<pre class="pre screen"><code>$<span class="ph"><samp class="ph codeph">bx ic</samp></span> ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
68f6536a-82f registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">lets-chat</var>:latest <span class="q">""</span> 3 days ago Running 6 seconds ago 8080/tcp <var class="keyword varname">lets-chat</var>
9f73abc2-9a1 registry.<var class="keyword varname" data-hd-keyref="DomainName">domain_name</var>/<var class="keyword varname">$your_namespace</var>/<var class="keyword varname">mongo</var>:latest <span class="q">""</span> 3 days ago Running 3 days ago 27017/tcp <var class="keyword varname">lc-mongo</var></code></pre>
</li>
<li class="step stepexpand"><span class="cmd">List the available IP addresses.</span> Binding an IP address allows your single container web app to be accessible via the
internet. <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ips</code></pre>
</li>
<li class="step stepexpand">Optional: <span class="cmd">If no IP addresses are listed, request an IP address.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-request</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Choose an available IP address and bind it to the<var class="keyword varname"> lets-chat</var> container.</span> Note that if all of your IP addresses are already bound, you will need to <a href="container_cli_reference_cfic.html#container_cli_reference_cfic__ip_unbind">unbind an IP address</a> first. Replace this example IP address with an IP address
that you have available in your organization. <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> ip-bind <var class="keyword varname">192.0.2.100</var> lets-chat</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Wait for the binding of the IP address to finish.</span> <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> inspect lets-chat</code></pre>
As
soon as the IP address is bound to your container, it is listed as
<span class="ph uicontrol">PublicIpAdress</span> in the <span class="ph uicontrol">Networks</span> section of your CLI
output.<pre class="pre screen"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> inspect lets-chat
...
<span class="q">"PortMapping"</span>: null,
<span class="q">"Ports"</span>: {
<span class="q">"8080/tcp"</span>: [
{
<span class="q">"HostIp"</span>: <span class="q">"192.0.2.100"</span>,
<span class="q">"HostPort"</span>: <span class="q">"8080"</span>
}
]
},
<span class="q">"PublicIpAddress"</span>: <span class="q">"192.0.2.100"</span>
...</code></pre>
</li>
<li class="step stepexpand"><span class="cmd">Go look at the web app that is up and running! Paste the bound public IP address into a web
browser, including the port.</span> <pre class="codeblock"><code>http://<var class="keyword varname">192.0.2.100</var>:8080</code></pre>
<p><img src="images/lets-chat_screenshot.jpg" alt="Sign in to the Let's Chat web app."></p>
</li>
<li class="step stepexpand">Optional: <span class="cmd">Create an account in Let's Chat and log in to see your web app running in
IBM Containers!</span> <p><img src="images/lets-chat-room.png" alt="lets-chat room"></p>
</li>
<li class="step stepexpand">Optional: <span class="cmd">Stop your containers.</span> If you don't want your containers consuming resources, you can stop and remove them. <pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> stop <var class="keyword varname">lets-chat</var> <var class="keyword varname">lc-mongo</var></code></pre>
<pre class="codeblock"><code><span class="ph"><samp class="ph codeph">bx ic</samp></span> rm <var class="keyword varname">lets-chat</var> <var class="keyword varname">lc-mongo</var></code></pre>
</li>
</ol>
<div class="section result" id="container_gettingstarted_tutorial_lesson_3__quiz">Test your knowledge! Now that you completed the tutorial, <a href="http://ibmcloud-quizzes.mybluemix.net/containers/single_containers_gettingstarted_tutorial/quiz.php" rel="external" target="_blank" title="(Opens in a new tab or window)">take a quiz to see what you learned</a>.</div><div class="section postreq"><div class="p"> What do you do next? There are many other <span class="keyword">IBM
Cloud Container Service</span> features you can apply to this tutorial:<ul><li>Try replacing single containers with <a href="container_ha.html#container_group_ui" title="Create and deploy a scalable group container from the Cloud GUI. A container group includes two or more containers that run the same image. Use container groups for running long-term services with workloads that require scalability and reliability or for testing at the required scale.">highly available container groups</a>, and enable auto-recovery, which
automatically replaces unavailable containers</li>
<li>Create and mount <a href="container_volumes_ov.html#container_volumes_ui" title="A volume is a persistent storage location for the data that an app creates or the files that the app requires to run. You can create a volume for your container from the Cloud GUI.">storage
volumes</a> to your mongo and lets-chat containers so that container data can be persisted across
container restarts and accessed by multiple containers in your private network</li>
</ul>
… and more. Get started today.</div>
</div></div>
</article></article><article class="topic tutorial tutorialIntro nested1" role="article" aria-labelledby="d72924e3789" lang="en-us" id="container_compose_intro"><h2 class="topictitle2" id="d72924e3789">Tutorial: Creating a multi-container deployment with Docker Compose and <span class="keyword">IBM
Cloud Container Service</span></h2>
<div class="body tutorialIntroBody"><p class="shortdesc">If you have apps with multiple components, such as databases, services and caches,
orchestrating all containers to start up and shut down together, can be a hard thing to do. In this
tutorial, you learn how to deploy and run your app as a multi-container deployment in a
microservices architecture by using a single Docker Compose command. Each container that is part of
this system, is based on a Docker Compose service definition, and runs in its own isolated
environment. </p>
<section class="section learningObjectives tutorialLearningObjectives" role="region" aria-labelledby="d72924e3849"><h3 class="sectiontitle" id="d72924e3849">Scenario</h3>This tutorial showcases how software developers can use
Docker Compose and <span class="keyword">IBM
Cloud Container Service</span> to deploy a
multi-container deployment that runs the Lets-Chat web app that is linked to a Mongo database and to
a nginx load balancer that balances incoming user traffic. <div class="p"><figure class="fignone" id="container_compose_intro__fig_compose"><figcaption>Figure 2. Target scenario for your multi-container Lets-Chat app</figcaption><div class="image"><img src="images/container_compose_tutorial.png" width="700" alt="Target scenario for your multi-container Lets-Chat app"></div></figure>
</div>
<div class="p">You walk through these lessons.<dl><dt class="dlterm"><a href="container_single_ui.html#container_compose_config" title="First, you configure each service of your multi-container deployment in a YAML file that is named docker-compose.yml. For each service, you specify the image, ports to expose, as well as the links to other services in the system.">Lesson