Tag - docker

jenkins docker tomcat java restful shell    2017-07-19 21:50:48    760

前提:jenkins是装在CentOS6.7中,同时,我的这台linux上面安装有docker


一、项目代码:

项目主要是jersey 1.x 版本的maven项目,重点在与我在项目中放置了tomcat,以及使用maven对tomcat进行解压,并将项目打包的文件放置到项目中,那么项目信息就不多写了,把maven配置信息重点写出来吧:

    <build>
        <finalName>testjersey</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <id>copy-package</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>

                                <unzip dest="target/apache/">
                                    <fileset dir="${basedir}">
                                        <include name="apache-tomcat-7.0.68.zip" />
                               
docker 微服务 MicroService    2017-07-19 21:30:08    805
本项目是将restful项目打包成可执行的war包,在docker中执行

环境介绍:

    docker    1.10.3
    jetty    8
    jersey    1.19

关键配置:
1、pom.xml配置
<build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.version}</version>
                <configuration>
                    <systemProperties>
                    </systemProperties>
                    <webApp>
                        <contextPath>/</contextPath>
                    </webApp>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </pl
docker    2017-07-19 21:23:55    852
修改文件

# vi /usr/lib/systemd/system/docker.service

修改为如下方式
[Unit]
Description=Docker Application Container Engine
After=network.target docker.socket
Requires=docker.socket

[Service]
Type=notify
ExecStart=/usr/bin/docker daemon --tls=false -H unix:///var/run/docker.sock  -H tcp://0.0.0.0:2375
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0

[Install]
WantedBy=multi-user.target

重载配置文件:
    # systemctl daemon-reload

重启Docker
    # systemctl restart docker


 


 

by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(防止爬虫):http://blog.liuyingguang.cn
OpenBI问答社区:http://openbi.liuyingguang.cn/

docker    2017-07-19 21:06:10    805

Docker原错误:

ERROR: rpc error: code = 2 desc = "oci runtime error: could not synchronise with container process: not a directory"


分析原因:
应该是本地映射的目录在container中不存在导致的
看到github上有相同的错误:https://github.com/docker/docker/issues/23474

解决办法:
   检查本地映射的目录与container中的目录一致性(或者是否存在)
 
 

 

by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(防止爬虫):http://blog.liuyingguang.cn
OpenBI问答社区:http://openbi.liuyingguang.cn/

docker consul registrator    2017-07-19 21:01:41    1107

参考文章:http://gliderlabs.com/registrator/latest/user/quickstart/

 

Consul是强一致性的数据存储,使用gossip形成动态集群。它提供分级键/值存储方式,不仅可以存储数据,而且可以用于注册器件事各种任务,从发送数据改变通知到运行健康检查和自定义命令,具体如何取决于它们的输出

Registrator通过检查容器在线或者停止运行状态自动注册和去注册服务,它目前支持etcd、Consul和SkyDNS 2

 

单机运行 consul服务


# docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp --name node4  gliderlabs/consul-server:0.6 -bootstrap -advertise 192.168.10.138

通过http API 查看consul服务

 

# curl 192.168.10.138:8500/v1/catalog/services 

{"consul":[]}

运行 Registrator

# docker run -d  --name=registrator  --net=host  --volume=/var/run/docker.sock:/tmp/docker.sock   gliderlabs/registrator:latest  consul://192.168.10.138:8500

 

Running Redis


# docker run -d -P --name=redis redis

测试Registrator配置是否有效


 
# curl 192.168.10.138:8500/v1/catalog/services 
 
{"consul":[],"redis":[]}


# curl 192.168.10.138:8500/v1/catalog/service/redis

[{"Node":"23dcba46458b","Address":"192.168.10.138","ServiceID":"localhost.localdomain:redis:6379","ServiceName":"redis","ServiceTags":[],"ServiceAddress":"","Servi
1/3