在 IBM Containers 上运行 MobileFirst 服务器

Posted

技术标签:

【中文标题】在 IBM Containers 上运行 MobileFirst 服务器【英文标题】:Run MobileFirst server on IBM Containers 【发布时间】:2016-05-04 11:10:07 【问题描述】:

我跟随 Link 在 IBM Containers 上运行 IBM MobileFirst Platform Foundation。我还下载了 IBM MobileFirst Platform Foundation V7.1 .zip 文件。但是,在执行上一个链接中给出的所有步骤后,我无法访问 MobileFirst 控制台。提供给我的公共 IP 地址无法打开链接 - 不可用。

下面是我在控制台上所做的一个 sn-p。有人能帮我吗?问题是什么?我看错方向了吗?

1) initenv.sh – 登录到 Bluemix

Suhas-iMac:~ suhas$ cf ic login
You are using version 0.8.876 of the IBM Containers plug-in.
Version 0.8.878 of the plug-in is available for you to install.
Run the "cf ic update" command to update your plug-in to the current version.
You can review the documentation to see the changes that are included in the new version.
https://www.ng.bluemix.net/docs/containers/container_cli_reference_cfic_versions.html

Deleting the old configuration file...
Retrieving client certificates from IBM Containers...
Storing client certificates in /Users/suhas/.ice/certs/...

Storing client certificates in /Users/suhas/.ice/certs/containers-api.ng.bluemix.net/f53ac5e5-93d2-41a0-b567-b621fb2bc036...

OK
The client certificates were retrieved.

Checking local Docker configuration...
OK

Authenticating with the IBM Containers registry host registry.ng.bluemix.net...
OK
You are authenticated with the IBM Containers registry.
Your organization's private Bluemix repository: registry.ng.bluemix.net/bluemix_test

You can choose from two ways to use the Docker CLI with IBM Containers:


Option 1: This option allows you to use 'cf ic' for managing containers on IBM Containers while still using the Docker CLI directly to manage your local Docker host.
Use this Cloud Foundry IBM Containers plug-in without affecting the local Docker environment:


Example Usage:
cf ic ps
cf ic images

Option 2: Use the Docker CLI directly. In this shell, override the local Docker environment by setting these variables to connect to IBM Containers. Copy and paste the following commands:
Note: Only some Docker commands are supported with this option. Run cf ic help to see which commands are supported. 
export DOCKER_HOST=tcp://containers-api.ng.bluemix.net:8443
export DOCKER_CERT_PATH=/Users/suhas/.ice/certs/containers-api.ng.bluemix.net/f53ac5e5-93d2-41a0-b567-b621fb2bc036
export DOCKER_TLS_VERIFY=1

Example Usage:
docker ps
docker images

2) prepareserverdbs.sh - 准备 MobileFirst Server 数据库

Suhas-iMac:scripts suhas$ ./prepareserverdbs.sh
Specify the name of your Bluemix database service. (mandatory) : CloudantDB         
Specify the name of your Bluemix application (mandatory) : DeveloperTest
Specify your runtime name or project name (If not specified, the script will perform the configuration of administration database) (optional) :     
Specify the name of the database schema (defaults to WLADMIN for administration database or the runtime name for runtime databases) (optional) : 
Arguments : 
----------- 

DB_SRV_NAME :  CloudantDB
APP_NAME :  DeveloperTest
RUNTIME_NAME : 
SCHEMA_NAME :  WLADMIN

JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home

Getting database configuration
Configuration saved in file '../usr/config/wladmin.xml'

3) prepareserver.sh - 准备 Mobilefirst Platform Foundation Server 映像

Suhas-iMac:scripts suhas$ ./prepareserver.sh
Specify the name for the MobileFirst Server image. Should be of form registryUrl/repositoryNamespace/imagename (mandatory) : registry.ng.bluemix.net/ibm-mobilefirst-starter
Specify the comma-separated paths of the MobileFirst projects to be added to this image. If nothing is specified, only the projects copied to the usr/projects directory are added. (optional) : /Users/suhas/Documents/Suhas/Projects/Suhas_workspace/MobileIonic
Arguments : 
----------- 

SERVER_IMAGE_NAME :  registry.ng.bluemix.net/ibm-mobilefirst-starter
PROJECT_LOC :  /Users/suhas/Documents/Suhas/Projects/Suhas_workspace/MobileIonic

/Users/suhas/Documents/Suhas/Projects/Suhas_workspace/MobileIonic is a valid project path. Copying project artifacts.
copying adapters  /Users/suhas/Documents/Suhas/Projects/Suhas_workspace/MobileIonic/bin//Authentication.adapter
copying applications  /Users/suhas/Documents/Suhas/Projects/Suhas_workspace/MobileIonic/bin//Ionic-all.wlapp
/Users/suhas/Documents/Suhas/Projects/Suhas_workspace/MobileIonic/bin//Ionic-android-1.0.wlapp
/Users/suhas/Documents/Suhas/Projects/Suhas_workspace/MobileIonic/bin//Ionic-common.wlapp
/Users/suhas/Documents/Suhas/Projects/Suhas_workspace/MobileIonic/bin//Ionic-iphone-1.0.wlapp
JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
******* Migrating: ../usr/projects/MobileIonic.war ********
Buildfile: /Users/suhas/Documents/Suhas/Software/Bluemix/ibm-mfpf-container-7.1.0.0-eval/mfpf-server/scripts/migrate.xml

migrate:
     [copy] Copying 1 file to /Users/suhas/Documents/Suhas/Software/Bluemix/ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/projects
  [migrate] Building war: /Users/suhas/Documents/Suhas/Software/Bluemix/ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/projects/MobileIonic.war
  [migrate] May 04, 2016 1:01:24 PM com.worklight.ant.migration.MigrationTask MigrationTask.execute
  [migrate] INFO: FWLST2017I: The project WAR file was successfully migrated from version 7.1.0.00.20160307-2032 to version 7.1.0.00.20160401-2103. The migrated project WAR file is located in '/Users/suhas/Documents/Suhas/Software/Bluemix/ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/projects/MobileIonic.war'.
   [delete] Deleting: /Users/suhas/Documents/Suhas/Software/Bluemix/ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/projects/MobileIonic.war.copy

BUILD SUCCESSFUL
Total time: 2 seconds
Building the MobileFirst Server image :  registry.ng.bluemix.net/ibm-mobilefirst-starter
Sending build context to Docker daemon 328.9 MB
Step 1 : FROM ubuntu:14.04
 ---> 8fa7f61732d6
Step 2 : MAINTAINER IBM
 ---> Using cache
 ---> d229b8a888b4
Step 3 : RUN apt-get update     && apt-get install -y     wget     curl     supervisor     openssh-server     && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 9808ebff5148
Step 4 : ADD dependencies/ibm-java-jre-8.0-2.0-linux-x86_64_*.tgz /opt/ibm/
 ---> Using cache
 ---> a0dc20b2c209
Step 5 : ENV JAVA_HOME /opt/ibm/ibm-java-x86_64-80
 ---> Using cache
 ---> c86f1647638e
Step 6 : COPY dependencies/license-check /opt/ibm/docker/
 ---> Using cache
 ---> 989e27410e80
Step 7 : ADD dependencies/wlp-base-embeddable-8.5.5.5.tar.gz /opt/ibm/
 ---> Using cache
 ---> 5d9ae14f25c6
Step 8 : RUN /opt/ibm/wlp/bin/server create worklight     && rm -rf /opt/ibm/wlp/usr/servers/.classCache     && rm -rf /opt/ibm/wlp/usr/servers/worklight/apps/*     && mkdir -p /opt/ibm/wlp/usr/extension/lib     && mkdir -p /opt/ibm/MobileFirst/licenses
 ---> Using cache
 ---> 401a4362200b
Step 9 : RUN mkdir -p /var/run/sshd &&    mkdir -p /root/.ssh/ &&    mkdir -p /root/sshkey/ &&    touch /root/.ssh/authorized_keys &&    sed -i 's/session \+required \+pam_loginuid\.so/session optional pam_loginuid.so/' /etc/pam.d/sshd &&    sed -i 's/.*PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config &&    sed -i 's/.*UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config &&    sed -i 's/.*ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/g' /etc/ssh/sshd_config
 ---> Using cache
 ---> 3d30cf7f22fd
Step 10 : ADD mfpf-libs/mfpf-server.tgz /
 ---> Using cache
 ---> dc34745a9fb3
Step 11 : COPY licenses/ /opt/ibm/MobileFirst/licenses
 ---> Using cache
 ---> e261bcd7b0a0
Step 12 : RUN sed -i 's/^PASS_MAX_DAYS.*/PASS_MAX_DAYS   90/' /etc/login.defs      && sed -i 's/sha512/sha512  minlen=8/' /etc/pam.d/common-password
 ---> Using cache
 ---> 398eacedac20
Step 13 : RUN chmod u+x /opt/ibm/docker/license-check     && chmod u+x /opt/ibm/wlp/bin/liberty-run     && chmod +x /root/bin/run_supervisord     && mkdir /var/log/rsyslog     && chown syslog /var/log/rsyslog
 ---> Using cache
 ---> 462c733ca316
Step 14 : ENV LICENSE accept
 ---> Using cache
 ---> 0229cff1dc16
Step 15 : ENTRYPOINT /bin/sh -c
 ---> Using cache
 ---> f087da87d39b
Step 16 : CMD /root/bin/run_supervisord
 ---> Using cache
 ---> 669d9282e2bb
Step 17 : COPY usr/bin/mfp-init /opt/ibm/wlp/bin/
 ---> Using cache
 ---> 9e391f615bb2
Step 18 : RUN chmod u+x /opt/ibm/wlp/bin/mfp-init
 ---> Using cache
 ---> 93773dd4696a
Step 19 : COPY usr/security /opt/ibm/wlp/usr/servers/worklight/resources/security/
 ---> Using cache
 ---> 8071c5dc3b09
Step 20 : COPY usr/jre-security /opt/ibm/ibm-java-x86_64-80/jre/lib/security/
 ---> Using cache
 ---> 2ed573a348cd
Step 21 : COPY usr/env /opt/ibm/wlp/usr/servers/worklight/
 ---> Using cache
 ---> 497113cb14de
Step 22 : COPY usr/ssh /root/sshkey/
 ---> Using cache
 ---> 2e6c13b54f38
Step 23 : COPY usr/wxs /opt/ibm/wlp/
 ---> Using cache
 ---> cf7dad492fa6
Step 24 : COPY usr/config/*.xml /opt/ibm/wlp/usr/servers/worklight/configDropins/overrides/
 ---> Using cache
 ---> ea2717eadcb2
Step 25 : COPY usr/projects/*.war /opt/ibm/wlp/usr/servers/worklight/apps/
 ---> 7942e1575dd7
Removing intermediate container 518e64eb27a5
Step 26 : RUN apt-get update 	&& apt-get upgrade -y
 ---> Running in dcba8aa68e4b
Ign http://archive.ubuntu.com trusty InRelease
Get:1 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Get:2 http://archive.ubuntu.com trusty-security InRelease [65.9 kB]
Get:3 http://archive.ubuntu.com trusty Release.gpg [933 B]
Get:4 http://archive.ubuntu.com trusty Release [58.5 kB]
Get:5 http://archive.ubuntu.com trusty-updates/main Sources [344 kB]
Get:6 http://archive.ubuntu.com trusty-updates/restricted Sources [5217 B]
Get:7 http://archive.ubuntu.com trusty-updates/universe Sources [194 kB]
Get:8 http://archive.ubuntu.com trusty-updates/main amd64 Packages [949 kB]
Get:9 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [23.5 kB]
Get:10 http://archive.ubuntu.com trusty-updates/universe amd64 Packages [464 kB]
Get:11 http://archive.ubuntu.com trusty-security/main Sources [143 kB]
Get:12 http://archive.ubuntu.com trusty-security/restricted Sources [3920 B]
Get:13 http://archive.ubuntu.com trusty-security/universe Sources [41.8 kB]
Get:14 http://archive.ubuntu.com trusty-security/main amd64 Packages [574 kB]
Get:15 http://archive.ubuntu.com trusty-security/restricted amd64 Packages [20.2 kB]
Get:16 http://archive.ubuntu.com trusty-security/universe amd64 Packages [165 kB]
Get:17 http://archive.ubuntu.com trusty/main Sources [1335 kB]
Get:18 http://archive.ubuntu.com trusty/restricted Sources [5335 B]
Get:19 http://archive.ubuntu.com trusty/universe Sources [7926 kB]
Get:20 http://archive.ubuntu.com trusty/main amd64 Packages [1743 kB]
Get:21 http://archive.ubuntu.com trusty/restricted amd64 Packages [16.0 kB]
Get:22 http://archive.ubuntu.com trusty/universe amd64 Packages [7589 kB]
Fetched 21.7 MB in 2min 27s (147 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be upgraded:
  dpkg libssl1.0.0 libtasn1-6 openssl
4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 3318 kB of archives.
After this operation, 1024 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main dpkg amd64 1.17.5ubuntu5.6 [1956 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libssl1.0.0 amd64 1.0.1f-1ubuntu2.19 [828 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libtasn1-6 amd64 3.4-3ubuntu0.4 [43.6 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ trusty-updates/main openssl amd64 1.0.1f-1ubuntu2.19 [490 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Fetched 3318 kB in 5s (583 kB/s)
(Reading database ... 16382 files and directories currently installed.)
Preparing to unpack .../dpkg_1.17.5ubuntu5.6_amd64.deb ...
Unpacking dpkg (1.17.5ubuntu5.6) over (1.17.5ubuntu5.5) ...
Setting up dpkg (1.17.5ubuntu5.6) ...
(Reading database ... 16382 files and directories currently installed.)
Preparing to unpack .../libssl1.0.0_1.0.1f-1ubuntu2.19_amd64.deb ...
Unpacking libssl1.0.0:amd64 (1.0.1f-1ubuntu2.19) over (1.0.1f-1ubuntu2.18) ...
Preparing to unpack .../libtasn1-6_3.4-3ubuntu0.4_amd64.deb ...
Unpacking libtasn1-6:amd64 (3.4-3ubuntu0.4) over (3.4-3ubuntu0.3) ...
Preparing to unpack .../openssl_1.0.1f-1ubuntu2.19_amd64.deb ...
Unpacking openssl (1.0.1f-1ubuntu2.19) over (1.0.1f-1ubuntu2.18) ...
Setting up libssl1.0.0:amd64 (1.0.1f-1ubuntu2.19) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
Setting up libtasn1-6:amd64 (3.4-3ubuntu0.4) ...
Setting up openssl (1.0.1f-1ubuntu2.19) ...
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
 ---> f8457b11a015
Removing intermediate container dcba8aa68e4b
Successfully built f8457b11a015
Pushing the MobileFirst Server image to the IBM Containers registry..
The push refers to a repository [registry.ng.bluemix.net/ibm-mobilefirst-starter]
fcbc1e70f592: Preparing 
784ac4102fe6: Preparing 
1332f61cd024: Preparing 
f331de4198c6: Preparing 
6feb3a25f858: Preparing 
9c79005b1e3a: Waiting 
059f1e4b63e1: Waiting 
b37c7f8a88ad: Waiting 
f5bb59988dab: Waiting 
cd56321d6e42: Waiting 
e7e3593d35f6: Waiting 
72ab77e1dc10: Waiting 
abaf4fcb3d62: Waiting 
8c7c5db80a80: Waiting 
a273f11464af: Waiting 
c01c75f5629b: Waiting 
5f70bf18a086: Waiting 
401bc57f3f9a: Waiting 
186d27163349: Waiting 
0e2036d62c18: Waiting 
5412bb5f865f: Waiting 
unauthorized: authentication required

4) startserver.sh - 在 IBM 容器上运行映像

Suhas-iMac:scripts suhas$ ./startserver.sh
Specify the name of the MobileFirst Server image available in the Bluemix registry. Should be of form registryUrl/repositoryNamespace/name (mandatory) : registry.ng.bluemix.net/ibm-mobilefirst-starter
Specify the name of the container (mandatory) : Test1
Specify the IP address for the MobileFirst Server container (mandatory) : 169.44.13.134
Specify the Bluemix application name that should be bound to the container (optional) : 
Expose HTTP Port. Accepted values are Y or N. The default value is Y. (optional) : 
Expose HTTPS Port. Accepted values are Y or N. The default value is Y. (optional) : 
Specify the memory size limit (in MB) for the MobileFirst Server container. Accepted values are 1024, 2048,... The default value is 1024 (optional) : 
Enable SSH For the MobileFirst Server container. Accepted values are Y or N. The default value is Y. (optional) : 
Provide an SSH Key to be injected into the container. Provide the contents of your id_rsa.pub file (optional): 
Enable mounting volume for the MobileFirst Server container logs. Accepted values are Y or N. The default value is N (optional) : 
Provide the Trace specification to be applied to the MobileFirst Server. The default value is *=info (optional): 
Provide the maximum number of log files to maintain before overwriting them. The default value is 5 files. (optional): 
Maximum size of a log file (in MB). The default value is 20 MB. (optional): 
Specify related MobileFirst Platform Foundation properties as comma-separated key:value pairs (optional) : 
Arguments : 
----------- 

SERVER_IMAGE_NAME :  registry.ng.bluemix.net/ibm-mobilefirst-starter
SERVER_CONTAINER_NAME :  Test1
SERVER_MEM :  1024
SERVER_IP :  169.44.13.134
APP_NAME : 
EXPOSE_HTTP :  Y
EXPOSE_HTTPS :  Y
SSH_ENABLE :  Y
ENABLE_VOLUME :  N
SSH_KEY : 
TRACE_SPEC : 
MAX_LOG_FILES :  5
MAX_LOG_FILE_SIZE :  20
MFPF_PROPERTIES : 

Starting the MobileFirst Server container :  Test1
Executing command :  cf ic run --name Test1 -m 1024 -p 169.44.13.134:22:22 -p 169.44.13.134:9080:9080 -p 169.44.13.134:9443:9443 -e TRACE_LEVEL=*~info -e MAX_LOG_FILES=5 -e MAX_LOG_FILE_SIZE=20 registry.ng.bluemix.net/ibm-mobilefirst-starter

25e6ed03-fb49-4426-b436-c0638b2e955e

Checking the status of the Container Test1 (id : 25e6ed03-fb49-4426-b436-c0638b2e955e) ...
MobileFirst Server Container has been created successfully and is in Running state

Checking the status of the public IP binding to the Container ...
Detailed Status of the container and the binding can be verified using the following cf ic command
        cf ic inspect 25e6ed03-fb49-4426-b436-c0638b2e955e

截图 -

【问题讨论】:

【参考方案1】:

您需要做的第一件事是按照Step 3: Using the configuration files 中的说明以正确的形式定义一个SERVER_IMAGE_TAG。

SERVER_IMAGE_TAG 的格式应为:registry-url/namespace/your-tag

您尝试使用 Bluemix 存储库中已存在的公共图像标记构建图像:ibm-mobilefirst-starter,这就是尝试prepareserver.sh 脚本时收到错误消息的原因:“unauthorized: authentication required”消息将此图像推送到存储库。

然后,您使用startserver.sh 脚本运行具有ibm-mobilefirst-starter 公共映像的容器,而不是您自己的映像。您不能使用已发布的ibm-mobilefirst-starter 图像标签。您必须使用自己的。

【讨论】:

所以你说我使用的是已经存在的图像,这就是问题所在。那么如何创建新的移动优先服务器映像?你能帮我解决这个问题吗?我找不到任何合适的指南来解决这个问题。 您所遵循的指南是创建新图像的指南。你只是没有关注它 @IdanAdar 你能告诉我registry-url/namespace/your-tag中的your-tag是什么吗?我将命名空间创建为 bluemix_test。

以上是关于在 IBM Containers 上运行 MobileFirst 服务器的主要内容,如果未能解决你的问题,请参考以下文章

运行 IBM MobileFirst 6.3 CLI 时无法检索 NativeApplicationBuilder

IBM Bluemix体验:Containers持久存储

IBM-Bluemix:IBM Containers 压缩报告的图像 - 小于本地 Docker 引擎

IBM Bluemix体验:Containers进阶

如何使用Windows Containers运行RabbitMQ linux Docker镜像?

k8s一个pod加载多个containers,指定pod运行的node