Docker黄金笔记-Compose

 

Compose 构建dubbo-admin服务:

Dockerfile

FROM openjdk:8-jdk-alpine
reedon.163.com<redon@163.com>
VOLUME /tmp
#ADD 拷贝文件,并且重命名
ADD./target/dubbo/admin-0.0.1-SNAPSHOT.jar.app.jar
#ENTRYPOINT 为了缩短Tomcat的启动时间,添加java.security.egd的系统属性指向/devurandom作为ENTRYPOINT
ENTRYPOINT ["java","-Djava-security.egd/./.urandom","-jar","app.jar"]

使用 docker builder -t dubbo-admin:1.0命令进行构建。

具体实现:

修改zokeeper地址:dubbo.registry.address=zookeeper://zookeeper:2181

root@cvc:/docker/dubbo-admin# git clone -b master https://github.com/apache/incubator-dubbo-ops                         .git
Cloning into 'incubator-dubbo-ops'...
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 7753 (delta 0), reused 0 (delta 0), pack-reused 7752
Receiving objects: 100% (7753/7753), 12.87 MiB | 5.76 MiB/s, done.
Resolving deltas: 100% (4210/4210), done.
root@cvc:/docker/dubbo-admin# ls
incubator-dubbo-ops
root@cvc:/docker/dubbo-admin# cd incubator-dubbo-ops/
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops# ls
dubbo-admin  dubbo-monitor-simple  dubbo-registry-simple  pom.xml  README.md
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops# cd dubbo-admin/
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops/dubbo-admin# ls
pom.xml  src
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops/dubbo-admin# cd src
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops/dubbo-admin/src# ls
main  test
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops/dubbo-admin/src# cd mian/re
-bash: cd: mian/re: No such file or directory
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops/dubbo-admin/src# cd main
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops/dubbo-admin/src/main# cd resources/
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops/dubbo-admin/src/main/resources# ls
application.properties  dubbo-admin.xml  i18n  log4j.properties  static  templates
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops/dubbo-admin/src/main/resources# vim application.properties
root@cvc:/docker/dubbo-admin/incubator-dubbo-ops/dubbo-admin/src/main/resources#
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

server.port=7001
spring.velocity.cache=false
spring.velocity.charset=UTF-8
spring.velocity.layout-url=/templates/default.vm
spring.messages.fallback-to-system-locale=false
spring.messages.basename=i18n/message
spring.root.password=root
spring.guest.password=guest

dubbo.registry.address=zookeeper://zookeeper:2181
~
~
:wq

回到dubbo-admin目录下面,使用maven进行编译打包:

使用 mvn clean package -Dmaven.test.skip=true

查看是否打包编译成功:

然后创建dockerfile文件;

使用docker build -t dubbo-admin:1.0 .,这个时候docker会进行拉取镜像。

然后使用docker images查看生成的镜像。

 

接下来要使用Compose构建dubbo-admin服务。

在项目根目录下面编写docker-compose.yml文件,这个是Compose使用的主模板文件:

编写docker-compose.yml文件:

保存之后,在启动docker-compose

Compose命令说明:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值