qt containers_IBM Containers更新上的WordPress

qt containers

Back in May 2015, Miguel showed us all how to deploy WordPress on Bluemix using containers. Now you can use the official WordPress image from the Docker Hub instead of the custom image used in the previous tutorial!

早在2015年5月, Miguel向我们展示了如何使用容器在Bluemix上部署WordPress 。 现在,您可以使用Docker Hub中的官方WordPress映像,而不是上一教程中使用的自定义映像!



怎么样? (How?)

This tutorial assumes you have already installed docker, the cf cli, and the cf “ic” plugin. For instructions on how to install these, please refer to the bluemix docs.

本教程假定您已经安装了docker,cf cli和cf“ ic”插件。 有关如何安装这些组件的指示,请参考bluemix docs

步骤0:登录到Bluemix并定位您所需的空间 (Step 0: Log into Bluemix and target your desired space)

1

1

cf login a api.ng.bluemix.net

cf login a api . ng . bluemix . net

1

1

cf ic login

cf ic login

步骤1:将官方WordPress映像复制到您的IBM Containers Registry (Step 1: Copy the official WordPress image to your IBM Containers Registry)

1

1

cf ic cpi wordpress wordpress

cf ic cpi wordpress wordpress

As described in the Bluemix docs, “cpi” will automatically “Access a Docker Hub image or an image from your local registry and copy it to your private Bluemix repository.”

如Bluemix文档中所述,“ cpi”将自动“从本地注册表访问Docker Hub映像或映像,并将其复制到您的私有Bluemix存储库。”

步骤2:创建将用作WordPress文件系统的卷 (Step 2: Create the volume that will serve as the WordPress file system)

1

1

$ cf ic volume create [VOLUME]

$ cf ic volume create [ VOLUME ]

You can name the volume whatever you want but remember the name for when you run the container in step 4.

您可以随意命名卷,但要记住在步骤4中运行容器时的名称。

步骤3:建立服务 (Step 3: Create Services)

For this tutorial we are going to use the “ClearDB MySQL Database” service as well as the “Sendgrid” service that was in the optional portion of the previous tutorial. To create instances of these services using the CLI you would run:

对于本教程,我们将使用上一教程的可选部分中的“ ClearDB MySQL数据库”服务以及“ Sendgrid”服务。 要使用CLI创建这些服务的实例,请运行:

1

1

cf createservice cleardb spark [CLEARDB_SERVICE_INSTANCE]

cf create service cleardb spark [ CLEARDB_SERVICE_INSTANCE ]

1

1

cf createservice sendgrid free [SENDGRID_SERVICE_INSTANCE]

cf create service sendgrid free [ SENDGRID_SERVICE_INSTANCE ]

Refer to the Bluemix catalog for a comprehensive list of available services.

请参阅Bluemix目录以获取可用服务的完整列表。

步骤4:使用WordPress映像运行容器 (Step 4: Run the Container with the WordPress Image)

IBM Bluemix offers a consistent development model across its 3 compute options (cloud foundry, containers, and virtual machines) by allowing users to bind services to their application, container, or virtual machine.

通过允许用户将服务绑定到其应用程序,容器或虚拟机,IBM Bluemix在其3个计算选项(云铸造厂,容器和虚拟机)中提供了一致的开发模型。

The credentials for interacting with the service are injected into your application/container/VM via a special environment variable named VCAP_SERVICES.

与服务交互的凭据通过名为VCAP_SERVICES的特殊环境变量注入到您的应用程序/容器/ VM中。

In the case of containers, the service will also flatten the JSON structure of this environment variable as follows:

对于容器,该服务还将按以下方式展平此环境变量的JSON结构:

1

1

2

2

3

3

4

4

5

5

6

6

7

7

8

8

9

9

10

10

11

11

12

12

13

13

14

14

15

15

16

16

17

17

18

18

{

{

  “cleardb”: [

   “cleardb” : [

    {

     {

      “name”: “mydb”,

       “name” : “mydb” ,

      “label”: “cleardb”,

       “label” : “cleardb” ,

      “plan”: “spark”,

       “plan” : “spark” ,

      “credentials”: {

       “credentials” : {

        “jdbcUrl”: “”,

         “jdbcUrl” : “” ,

        “uri”: “”,

         “uri” : “” ,

        “name”: “”,

         “name” : “” ,

        “hostname”: “”,

         “hostname” : “” ,

        “port”: “”,

         “port” : “” ,

        “username”: “”,

         “username” : “” ,

        “password”: “”

         “password” : “”

      }

       }

    }

     }

  ]

   ]

}

}

These are some example credentials as they would appear on the IBM Bluemix console.

这些是一些示例凭证,就像它们将出现在IBM Bluemix控制台上一样。

1

1

2

2

3

3

4

4

5

5

6

6

VCAP_SERVICES_CLEARDB_0_NAME

VCAP_SERVICES_CLEARDB_0_NAME

VCAP_SERVICES_CLEARDB_0_LABEL

VCAP_SERVICES_CLEARDB_0_LABEL

VCAP_SERVICES_CLEARDB_0_PLAN

VCAP_SERVICES_CLEARDB_0_PLAN

VCAP_SERVICES_CLEARDB_0_CREDENTIALS_JDBCURL

VCAP_SERVICES_CLEARDB_0_CREDENTIALS_JDBCURL

VCAP_SERVICES_CLEARDB_0_CREDENTIALS_URI

VCAP_SERVICES_CLEARDB_0_CREDENTIALS _ URI

...

. . .

This is how the same credentials would appear after being flattened.

这是相同的凭据在展平后将显示的方式。

To run the official WordPress image on IBM containers, we can map these VCAP_SERVICES environment variables to the ones expected by the image as part of our run command:

要在IBM容器上运行官方WordPress映像,我们可以将这些VCAP_SERVICES环境变量映射到该映像所需的变量,作为运行命令的一部分:

1

1

2

2

3

3

4

4

5

5

6

6

cf ic run p 80 v [VOLUME]:/wpcontent e CCS_BIND_SRV=“[CLEARDB_SERVICE_INSTANCE],[SENDGRID_SERVICE_INSTANCE]”

cf ic run p 80 v [ VOLUME ] : / wp content e CCS_BIND_SRV = “[CLEARDB_SERVICE_INSTANCE],[SENDGRID_SERVICE_INSTANCE]”

e WORDPRESS_DB_HOST=‘${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_HOSTNAME}:${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_PORT}’

e WORDPRESS_DB_HOST = ‘${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_HOSTNAME}:${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_PORT}’

e WORDPRESS_DB_USER=‘${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_USERNAME}’

e WORDPRESS_DB_USER = ‘${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_USERNAME}’

e WORDPRESS_DB_PASSWORD=‘${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_PASSWORD}’

e WORDPRESS_DB_PASSWORD = ‘${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_PASSWORD}’

e WORDPRESS_DB_NAME=‘${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_NAME}’

e WORDPRESS_DB_NAME = ‘${VCAP_SERVICES_CLEARDB_0_CREDENTIALS_NAME}’

registry.ng.bluemix.net/[NAMESPACE]/wordpress sh c ‘eval “$(env | grep WORDPRESS)” && /entrypoint.sh apache2-foreground’

registry . ng . bluemix . net / [ NAMESPACE ] / wordpress sh c ‘eval “$(env | grep WORDPRESS)” && /entrypoint.sh apache2-foreground’

If you are working from a Windows machine you must run the command from the

如果您使用的是Windows计算机,则必须从

Docker Quickstart Terminal.

Docker快速入门终端。

Specifically, this command sets each WORDPRESS variable to the name of the corresponding VCAP_SERVICES variable, then passes a command which evaluates these assignments on the container before running the image’s normal entrypoint.

具体来说,此命令将每个WORDPRESS变量设置为相应的VCAP_SERVICES变量的名称,然后传递一个命令,该命令在运行映像的常规入口点之前对容器上的这些分配进行评估。

note:Make sure to replace [VOLUME], [NAMESPACE], [CLEARDB_SERVICE_INSTANCE], and [SENDGRID_SERVICE_INSTANCE] with their respective values.

注意:请确保将[VOLUME],[NAMESPACE],[CLEARDB_SERVICE_INSTANCE]和[SENDGRID_SERVICE_INSTANCE]替换为其各自的值。

步骤5:请求和绑定IP (Step 5: Requesting and Binding an IP)

Check on the status of your new container:

检查新容器的状态:

1

1

cf ic ps a

cf ic ps a

Pay special attention to the PORTS column. We want it to contain your desired IP and port. If it is missing an IP, then you will need to request a new one (or unbind an existing one) and bind it.To print your current list of IPs, run:

要特别注意“ PORTS”列。 我们希望它包含您所需的IP和端口。 如果缺少IP,则需要请求一个新IP(或取消绑定现有IP)并将其绑定。要打印当前IP列表,请运行:

1

1

cf ic ip list

cf ic ip list

To request a new IP (free trial accounts are currently limited to 2):

要申请新IP(免费试用帐户目前限于2个):

1

1

cf ic ip request

cf ic ip request

To bind it to your container:

要将其绑定到您的容器:

1

1

cf ic ip bind [YOUR_IP] [YOUR_CONTAINER]

cf ic ip bind [ YOUR_IP ] [ YOUR_CONTAINER ]

After binding the IP to the container you will access WordPress by typing the bound IP into your browser.

将IP绑定到容器后,您将通过在浏览器中键入绑定的IP来访问WordPress。

在WordPress容器中设置电子邮件(可选): (Setting up email in your WordPress Container (optional):)

The container does not have an SMTP server configuration and so the WordPress email functionality will not work. We can use the SendGrid plugin to remedy this. In step 3 we bound a SendGrid service instance to our container. Now it is just a matter of installing the plugin and setting credentials.

该容器没有SMTP服务器配置,因此WordPress电子邮件功能将无法使用。 我们可以使用SendGrid插件对此进行补救。 在步骤3中,我们将SendGrid服务实例绑定到了我们的容器。 现在只需安装插件并设置凭据即可。

步骤1.在您的WordPress实例中安装SendGrid插件。 (Step 1. Install the SendGrid plugin in your WordPress instance.)

The plugin can be installed in the wordpress ui (Plugins > AddNew > Search (Sendgrid))Once it is installed, make sure to activate it.

8c

该插件可以安装在wordpress ui中(插件> AddNew> Search(Sendgrid))。一旦安装,请确保将其激活。

步骤2.设置凭据 (Step 2. Set Credentials)

Go to Plugins > Installed Plugins > SendGrid Settings

8d

转到插件>已安装的插件> SendGrid设置

To fill out the username and password, you will need to print the credentials that were created when you bound this service instance to your container. To accomplish the binding and unbinding of service instances to a container, IBM Containers uses the Cloud Foundry Service Keys feature that was contributed in the summer of 2015.

要填写用户名和密码,您将需要打印将该服务实例绑定到容器时创建的凭据。 为了完成服务实例与容器的绑定和解除绑定,IBM Containers使用了Cloud Foundry 服务密钥功能,该功能于2015年夏季提供

While normally the credentials are injected into your running container, sometimes it is easier to just print the credentials and copy/paste them to the corresponding fields. To obtain the SendGrid username and password, you must first find the corresponding service key by running:

虽然通常将凭据注入到正在运行的容器中,但有时仅打印凭据并将其复制/粘贴到相应字段会更容易。 要获取SendGrid用户名和密码,必须首先通过运行以下命令找到相应的服务密钥:

1

1

cf servicekeys [SENDGRID_SERVICE_INSTANCE]

cf service keys [ SENDGRID_SERVICE_INSTANCE ]

Once you find the service key associated with your running container (the container name should be in the key), you can retrieve the SendGrid credentials:

找到与正在运行的容器关联的服务密钥(容器名称应在密钥中)后,您可以检索SendGrid凭据:

1

1

cf servicekey [SENDGRID_SERVICE_INSTANCE] [SERVICE_KEY]

cf service key [ SENDGRID_SERVICE_INSTANCE ] [ SERVICE_KEY ]

Fill in the Username and Password fields from the service key credentials and proceed to configure your own mail settings. You can try sending a test email from the same page. If the email is sent properly, then your WordPress installation is complete!

从服务密钥凭据中填写“用户名”和“密码”字段,然后继续配置您自己的邮件设置。 您可以尝试从同一页面发送测试电子邮件。 如果电子邮件发送正确,则说明您的WordPress安装已完成!



Luke Stack

Luke joined IBM’s jStart team as a co-op in January 2016 . Luke is a junior, pursuing Bachelor’s of Science degrees in both Computer Science and Mathematics at Appalachian State University.

Luke于2016年1月加入IBM的jStart团队作为合作社。 Luke是一名大三学生,在阿巴拉契亚州立大学获得计算机科学和数学的理学学士学位。

Luke Stack
Luke Stack
Luke Stack

翻译自: https://www.pybloggers.com/2016/01/wordpress-on-ibm-containers-update/

qt containers

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值