<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.test.skip>true</maven.test.skip>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
<dockerfile.maven.version>1.4.3</dockerfile.maven.version>
<docker.image.prefix>registry.docker.com:5000</docker.image.prefix>
<appPort>8880</appPort>
</properties>
<finalName>${project.name}</finalName>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.13</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${docker.image.prefix}/${project.build.finalName}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
<APP_PORT>${appPort}</APP_PORT>
</buildArgs>
</configuration>
</plugin>
- springboot application.yml configuration
server:
report: @appport@
logging:
level:
root: info
spring:
application:
name: @project.name@
- Dockerfile File Configuration > tip: Put in Project Root
FROM hub.c.163.com/dwyane/openjdk:8
VOLUME /tmp
WORKDIR /workdir
ARG JAR_FILE
ARG APP_PORT
ADD target/${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","app.jar"]
EXPOSE ${APP_PORT}
- Execute mvn clean package > Access to Private Repository: http://registry.docker.com:5000/v2/_catalog
- Jenkins configuration
- Create maven project
- Build[Goals and options -> clean install -Dmaven.test.skip=true]
- Post Steps[Run only if build such]
- ad post-build step [Senegal files or executive orders over SSH]
cd $DOCKER_WORKSPACE/$JOB_NAME
export app_version='1.0'
tee $JOB_NAME.yml <<-'EOF'
version: '3.5'
services:
$JOB_NAME:
image: registry.docker.com:5000/$JOB_NAME:${app_version}
ports:
- target: 8880
published: 8880
mode: host
networks:
- middleware
deploy:
replicas: 1
update_config:
parallelism: 1
restart_policy:
condition: on-failure
networks:
middleware:
external: true
EOF
docker stack up -c $JOB_NAME.yml app
- Edit /etc/sysconfig/docker file, docker I installed. No such file found, if any,:
sudo vi /etc/sysconfig/docker
///add the following
other_args="-H tcp://0.0.0:2375 -H unix:////var/run/docker.sock"
/Save
:wq!
//reboot docker service
service docker restart
- Create a new DOCKER_HOST value in the windows system environment variable to tcp://[docker_ip]:2375, replace[docker_ip]here with a centeros server IP or hostname in which the docker is located (using hostname and requiring windows to configure hosts/hosts) and may require a restart of the system.
- Modify /usr/lib/systemd/system/docker.service file
sudo vi /usr/lib/systemd/system/docker.service
//在ExecStart这一行后面加上(这里就写4个0,别改成自己的ip)
-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
改完后效果如下
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
:wq!
保存退出
重新加载配置文件 systemctl daemon-reload
重启docker :service docker restart
这样才可以是/etc/default/docker中的配置项生效
- We first ask which ports docker's virtual machine is listening to, using command:
netstat -tlunp
sudo iptables-save
sudo firewall-cmd --zone=public --add-port=2375/tcp --permanent
sudo firewall
sudo firewald-cmd --reload