如何在minishift中运行基础centos图像?

时间:2018-01-22 17:09:50

标签: openshift minishift

我尝试了解Open Shift,它是如何工作的,如何运行应用程序,构建图像等。

从一些我认为相当简单的东西开始,我决定使用基于this图像的纯centos7操作系统运行一个pod。我在本地安装minishift v1.11.0+4459917,我创建了一个新项目,并执行了命令:     这个项目中oc new-app openshift/base-centos7。结果我收到以下消息:

--> Found Docker image bb81a09 (11 months old) from Docker Hub for "openshift/base-centos7"

    * An image stream will be created as "pon3:latest" that will track this image
    * This image will be deployed in deployment config "pon3"
    * The image does not expose any ports - if you want to load balance or send traffic to this component
      you will need to create a service with 'expose dc/pon3 --port=[port]' later
    * WARNING: Image "openshift/base-centos7" runs as the 'root' user which may not be permitted by your cluster administrator

--> Creating resources ...
    imagestream "pon3" created
    deploymentconfig "pon3" created
--> Success
    Run 'oc status' to view your app.

正如我在警告中看到的那样,这个图像以root身份运行,这显然不是一个好习惯,但它可以解决,如herehere所述。我尝试了两种方法 - 我使用anyuid scc创建了一个新的服务帐户,并将anyuid scc分配给default sa。很遗憾,我仍然无法根据此图片运行广告连播。结果如下:

oc get pods

mycentos-1-deploy         1/1       Running            0          32s
mycentos-1-p1vh5          0/1       CrashLoopBackOff   1          30s

我尝试以这种方式排除故障:

oc logs -p mycentos-1-p1vh5

This image serves as the base image for all OpenShift v3 S2I builder images.
It provides all essential libraries and development tools needed to
successfully build and run an application.

To use this image as a base image, you need to have 's2i/bin' directory in the
same directory as your S2I image Dockerfile. This directory should contain S2I
scripts.

This base image also provides the default user you should use to run your
application. Your Dockerfile should include this instruction after you finish
installing software:

USER default

The default directory for installing your application sources is
'/opt/app-root/src' and the WORKDIR and HOME for the 'default' user is set
to this directory as well. In your S2I scripts, you don't have to use absolute
path, but rather rely on the relative path.

To learn more about S2I visit: https://github.com/openshift/source-to-image

此外,我尝试使用oc adm diagnostics进行问题排查,但说实话,我没有看到与此问题相关的任何内容。

我在这里明显遗漏了一些东西。有人可以给我一个提示应该如何处理这个问题,或者我该如何解决这个问题呢?是否有不同的方式来运行纯的centos OS?

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

您需要使用oc new-app部署要部署的图像才能在其中包含实际应用程序。 openshift/base-centos7图像是基础图像,仅在其上构建其他图像且其中没有应用程序。

如果您只是想要启动一个容器并获得一个shell环境,您可以在其中使用oc run命令。

OpenShift与传统的VPS不同,您只需启动永久的shell环境,然后可以手动设置应用程序。我们的想法是将您的应用程序构建到映像中并部署应用程序。

我建议你去看看:

通过以下练习进行练习:

了解有关OpenShift的更多信息以及如何使用它。