阅读背景:

spring boot / cloud (十八) 使用docker快速搭建本地环境

来源:互联网 
$ sudo docker version
# 结果输出 :
Client:
Version: 17.09.0-ce-rc2
API version: 1.32
Go version: go1.8.3
Git commit: 363a3e7
Built: Thu Sep 14 01:54:43 2017
OS/Arch: linux/amd64

Server:
Version: 17.09.0-ce-rc2
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: 363a3e7
Built: Thu Sep 14 01:56:05 2017
OS/Arch: linux/amd64
Experimental: false
$ sudo mkdir /var/lib/mysql && chown -R 200 /var/lib/mysql
$ sudo docker run \ 
-d \
--restart=always \
-p 3306:3306 \
-e TZ="Asia/Shanghai" \
-v /etc/localtime:/etc/localtime:ro \
-v /var/lib/mysql:/var/lib/mysql \
--name mysql \
-e MYSQL_ROOT_PASSWORD=XXX \
wjrfy32i.mirror.aliyuncs.com/library/mysql:latest
$ sudo mkdir /var/lib/rabbitmq && chown -R 200 /var/lib/rabbitmq
$ sudo mkdir /var/log/rabbitmq && chown -R 200 /var/log/rabbitmq
$ sudo docker run \ 
-d \
--restart=always \
--hostname rabbitmq \
--name rabbitmq \
-p 15672:15672 \
-p 5672:5672 \
-e TZ="Asia/Shanghai" \
-v /etc/localtime:/etc/localtime:ro \
-v /var/lib/rabbitmq:/var/lib/rabbitmq \
-v /var/log/rabbitmq:/var/log/rabbitmq \
-e RABBITMQ_DEFAULT_USER=admin \
-e RABBITMQ_DEFAULT_PASS=xxx \
wjrfy32i.mirror.aliyuncs.com/library/rabbitmq:3.6.10-management-alpine
$ sudo mkdir /var/lib/redis && chown -R 200 /var/lib/redis
$ sudo mkdir /var/lib/redis_conf && chown -R 200 /var/lib/redis_conf
$ sudo docker run \ 
-d \
--restart=always \
--hostname redis \
--name redis \
-p 6379:6379 \
-e TZ="Asia/Shanghai" \
-v /etc/localtime:/etc/localtime:ro \
-v /var/lib/redis:/data \
-v /var/lib/redis_conf/redis.conf:/usr/local/etc/redis/redis.conf \
wjrfy32i.mirror.aliyuncs.com/library/redis:latest \
redis-server /usr/local/etc/redis/redis.conf
$ sudo mkdir /var/lib/nginx && chown -R 200 /var/lib/nginx
$ sudo mkdir /var/lib/nginx/conf.d && chown -R 200 /var/lib/nginx/conf.d
$ sudo mkdir /var/lib/nginx_conf && chown -R 200 /var/lib/nginx_conf
$ sudo mkdir /var/lib/nginx_content && chown -R 200 /var/lib/nginx_content
$ sudo mkdir /var/log/nginx && chown -R 200 /var/log/nginx
$ sudo mkdir /var/lib/nginx_file && chown -R 200 /var/lib/nginx_file
$ sudo docker run -d --hostname nginx --name nginx -p 80:80 wjrfy32i.mirror.aliyuncs.com/library/nginx:latest
$ sudo docker cp nginx:/etc/nginx/nginx.conf /var/lib/nginx/nginx.conf
$ sudo docker cp nginx:/etc/nginx/conf.d/default.conf /var/lib/nginx/conf.d/default.conf
$ sudo docker cp nginx:/usr/share/nginx/html/50x.html /var/lib/nginx_content/50x.html
$ sudo docker cp nginx:/usr/share/nginx/html/index.html /var/lib/nginx_content/index.html
$ sudo docker rm -f nginx
$ sudo docker run \ 
-d \
--restart=always \
--hostname nginx \
--name nginx \
--link=rabbitmq:rabbitmq \
-p 81:81 \
-e TZ="Asia/Shanghai" \
-v /etc/localtime:/etc/localtime:ro \
-v /var/lib/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \
-v /var/lib/nginx/conf.d:/etc/nginx/conf.d:ro \
-v /var/lib/nginx_content:/usr/share/nginx/html:ro \
-v /var/lib/nginx_file:/usr/share/nginx/file:ro \
-v /var/log/nginx:/var/log/nginx \
wjrfy32i.mirror.aliyuncs.com/library/nginx:latest
<!-- docker -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>192.168.1.10:5000/${project.groupId}/${project.artifactId}:latest</imageName>
<baseImage>192.168.1.10:5000/org.itkk/java:8</baseImage>
<maintainer>[email protected]</maintainer>
<exposes>${server.port}</exposes>
<cmd></cmd>
<entryPoint>["java","-jar","/${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
$ sudo mvn clean install package docker:build

分享到: