环境:OCP 3.3
1. 在 MAC OS X 上操作
scp example.war root@master.example.com:/root/
2. 在 master.example.com 上操作
mkdir example
cd example
mv /root/example.war .
vim Dockerfile
内容如下:
FROM registry.example.com:5000/jboss-webserver-3/webserver30-tomcat8-openshift:latest
USER root
RUN mkdir -p /home/vcap/app/logs1
COPY example.war $JWS_HOME/webapps/ROOT.war
oc login -u system:admin
oc label node node2.example.com app="yes"
oc login -u admin -p admin
oc new-project applications
oc login -u system:admin
oc annotate namespace applications openshift.io/node-selector='app=yes' --overwrite
3. 为了解决 ErrImagePull 问题,在 node2.example.com 上操作
systemctl stop docker
rm -rf /var/lib/docker/*
systemctl start docker
4. 在 master.example.com 上操作
cd .. 退到 example 上一级目录
oc login -u admin -p admin
oc new-app example --name=example --insecure-registry=true
输出如下:
--> Found Docker image 8bcae56 (5 months old) from registry.example.com:5000 for "registry.example.com:5000/jboss-webserver-3/webserver30-tomcat8-openshift:latest"
JBoss Web Server 3.0
--------------------
Platform for building and running web applications on JBoss Web Server 3.0 - Tomcat v8
Tags: builder, java, tomcat8
* An image stream will be created as "webserver30-tomcat8-openshift:latest" that will track the source image
* A Docker build using binary input will be created
* The resulting image will be pushed to image stream "example:latest"
* Use 'start-build --from-dir=DIR|--from-repo=DIR|--from-file=FILE' to trigger a new build
* WARNING: a binary build was created, you must specify one of --from-dir|--from-file|--from-repo when starting builds
* This image will be deployed in deployment config "example"
* Ports 8080/tcp, 8443/tcp, 8778/tcp will be load balanced by service "example"
* Other containers can access this service through the hostname "example"
--> Creating resources with label app=example ...
imagestream "webserver30-tomcat8-openshift" created
imagestream "example" created
buildconfig "example" created
deploymentconfig "example" created
service "example" created
--> Success
Use 'oc start-build example' to start a build.
Run 'oc status' to view your app.
oc start-build example --from-dir=example
输出如下:
Uploading directory "example" as binary input for the build ...
build "example-1" started
oc logs example-1-build
输出如下:
Receiving source from STDIN as archive ...
Step 1 : FROM registry.example.com:5000/jboss-webserver-3/webserver30-tomcat8-openshift
---> b920d965d356
Step 2 : USER root
---> Running in 168e32afb9e6
---> fae88d914298
Removing intermediate container 168e32afb9e6
Step 3 : RUN mkdir -p /home/vcap/app/logs1
---> Running in 56aa18776e47
---> c63383a6e268
Removing intermediate container 56aa18776e47
Step 4 : COPY example.war $JWS_HOME/webapps/ROOT.war
---> 9f2fabe78fe4
Removing intermediate container c3e346f170ff
Step 5 : ENV "OPENSHIFT_BUILD_NAME" "example-1" "OPENSHIFT_BUILD_NAMESPACE" "applications"
---> Running in 020f52d2bace
---> c6e8a97d67d4
Removing intermediate container 020f52d2bace
Successfully built c6e8a97d67d4
Pushing image 172.30.123.246:5000/applications/example:latest ...
Pushed 0/7 layers, 0% complete
Pushed 1/7 layers, 22% complete
Pushed 2/7 layers, 35% complete
Pushed 3/7 layers, 64% complete
Pushed 4/7 layers, 75% complete
Pushed 5/7 layers, 85% complete
Pushed 5/7 layers, 96% complete
Pushed 6/7 layers, 95% complete
Pushed 7/7 layers, 100% complete
Push successful
oc expose service example --hostname=example.apps.example.com
访问 http://example.apps.example.com/index.jsp
1. 在 MAC OS X 上操作
scp example.war root@master.example.com:/root/
2. 在 master.example.com 上操作
mkdir example
cd example
mv /root/example.war .
vim Dockerfile
内容如下:
FROM registry.example.com:5000/jboss-webserver-3/webserver30-tomcat8-openshift:latest
USER root
RUN mkdir -p /home/vcap/app/logs1
COPY example.war $JWS_HOME/webapps/ROOT.war
oc login -u system:admin
oc label node node2.example.com app="yes"
oc login -u admin -p admin
oc new-project applications
oc login -u system:admin
oc annotate namespace applications openshift.io/node-selector='app=yes' --overwrite
3. 为了解决 ErrImagePull 问题,在 node2.example.com 上操作
systemctl stop docker
rm -rf /var/lib/docker/*
systemctl start docker
4. 在 master.example.com 上操作
cd .. 退到 example 上一级目录
oc login -u admin -p admin
oc new-app example --name=example --insecure-registry=true
输出如下:
--> Found Docker image 8bcae56 (5 months old) from registry.example.com:5000 for "registry.example.com:5000/jboss-webserver-3/webserver30-tomcat8-openshift:latest"
JBoss Web Server 3.0
--------------------
Platform for building and running web applications on JBoss Web Server 3.0 - Tomcat v8
Tags: builder, java, tomcat8
* An image stream will be created as "webserver30-tomcat8-openshift:latest" that will track the source image
* A Docker build using binary input will be created
* The resulting image will be pushed to image stream "example:latest"
* Use 'start-build --from-dir=DIR|--from-repo=DIR|--from-file=FILE' to trigger a new build
* WARNING: a binary build was created, you must specify one of --from-dir|--from-file|--from-repo when starting builds
* This image will be deployed in deployment config "example"
* Ports 8080/tcp, 8443/tcp, 8778/tcp will be load balanced by service "example"
* Other containers can access this service through the hostname "example"
--> Creating resources with label app=example ...
imagestream "webserver30-tomcat8-openshift" created
imagestream "example" created
buildconfig "example" created
deploymentconfig "example" created
service "example" created
--> Success
Use 'oc start-build example' to start a build.
Run 'oc status' to view your app.
oc start-build example --from-dir=example
输出如下:
Uploading directory "example" as binary input for the build ...
build "example-1" started
oc logs example-1-build
输出如下:
Receiving source from STDIN as archive ...
Step 1 : FROM registry.example.com:5000/jboss-webserver-3/webserver30-tomcat8-openshift
---> b920d965d356
Step 2 : USER root
---> Running in 168e32afb9e6
---> fae88d914298
Removing intermediate container 168e32afb9e6
Step 3 : RUN mkdir -p /home/vcap/app/logs1
---> Running in 56aa18776e47
---> c63383a6e268
Removing intermediate container 56aa18776e47
Step 4 : COPY example.war $JWS_HOME/webapps/ROOT.war
---> 9f2fabe78fe4
Removing intermediate container c3e346f170ff
Step 5 : ENV "OPENSHIFT_BUILD_NAME" "example-1" "OPENSHIFT_BUILD_NAMESPACE" "applications"
---> Running in 020f52d2bace
---> c6e8a97d67d4
Removing intermediate container 020f52d2bace
Successfully built c6e8a97d67d4
Pushing image 172.30.123.246:5000/applications/example:latest ...
Pushed 0/7 layers, 0% complete
Pushed 1/7 layers, 22% complete
Pushed 2/7 layers, 35% complete
Pushed 3/7 layers, 64% complete
Pushed 4/7 layers, 75% complete
Pushed 5/7 layers, 85% complete
Pushed 5/7 layers, 96% complete
Pushed 6/7 layers, 95% complete
Pushed 7/7 layers, 100% complete
Push successful
oc expose service example --hostname=example.apps.example.com
访问 http://example.apps.example.com/index.jsp
没有评论:
发表评论