赞
踩
docker pull mysql
//下载MySQL镜像docker run --name mysql --restart=always -p 3306:3306 -e MYSQL_ROOT_PASSWORD=密码 -d mysql
docker search java8
docker pull williamyeh/java8
,跟后续讲到dockerfile我会详细讲解docker run --name redis --restart=always -p 6379:6379 -d redis --requirepass "密码"
docker run --name rabbit --restart=always -p 15672:15672 -p 5672:5672 -d rabbitmq:management
启动rabbitmq默认账号密码都是guest
artile:maxwell
email:send
email_queue: email_exchange
maxwell_quene:maxwell_exchange
FROM williamyeh/java8:latest
VOLUME /tmp
ADD zhi-admin.jar zhi-admin.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/zhi-admin.jar"]
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#源jar路径 SOURCE_PATH=/usr/local/docker #docker 镜像/容器名字或者jar名字 这里都命名为这个 SERVER_NAME=zhi-admin.jar TAG=latest SERVER_PORT=8080 #容器id CID=$(docker ps | grep "$SERVER_NAME" | awk '{print $1}') #镜像id IID=$(docker images | grep "$SERVER_NAME:$TAG" | awk '{print $3}') if [ -n "$CID" ]; then echo "存在容器$SERVER_NAME, CID-$CID" docker stop $CID docker rm $CID fi # 构建docker镜像 if [ -n "$IID" ]; then echo "存在$SERVER_NAME:$TAG镜像,IID=$IID" docker rmi $IID else echo "不存在$SERVER_NAME:$TAG镜像,开始构建镜像" cd $SOURCE_PATH docker build -t $SERVER_NAME:$TAG . fi # 运行docker容器 docker run --name $SERVER_NAME -v /usr/local/upload:/usr/local/upload -d -p $SERVER_PORT:$SERVER_PORT $SERVER_NAME:$TAG echo "$SERVER_NAME容器创建完成"
sh ./blog-start.sh
docker ps
查看:先忽略这里的nginx,后续会说到,首先看这里有没有出现zhi-admin.jar,如果没有出现,走下面的操作:docker images
:docker run -p 8080:8080 -d zhi-admin.jar
docker pull nginx
events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_max_body_size 50m; client_body_buffer_size 10m; client_header_timeout 1m; client_body_timeout 1m; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_comp_level 4; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary on; server { listen 80; server_name 你的服务器ip; location / { root /usr/local/vue/blog; index index.html index.htm; try_files $uri $uri/ /index.html; } location ^~ /api/ { proxy_pass http://你的服务器ip:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 81; server_name 你的服务器ip; location / { root /usr/local/vue/admin; index index.html index.htm; try_files $uri $uri/ /index.html; } location ^~ /prod-api/ { proxy_pass http://你的服务器ip:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 82; server_name 你的服务器ip; location / { proxy_pass http://你的服务器ip:8080/websocket; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } server { listen 83; server_name 你的服务器ip; location / { root /usr/local/upload/; } } }
events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_max_body_size 50m; client_header_timeout 1m; client_body_timeout 1m; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_comp_level 4; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary on; server { listen 80; server_name www.ftzlovedsj.com; location / { root /usr/local/vue/blog; index index.html index.htm; try_files $uri $uri/ /index.html; } location ^~ /api/ { proxy_pass http://81.70.253.100:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name www.admin.ftzlovedsj.com; location / { root /usr/local/vue/admin; index index.html index.htm; try_files $uri $uri/ /index.html; } location ^~ /prod-api/ { proxy_pass http://81.70.253.100:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 82; server_name 81.70.253.100; location / { alias /usr/local/upload/; autoindex on; autoindex_exact_size on; autoindex_localtime on; } } server { listen 80; server_name www.ws.ftzlovedsj.com; location / { proxy_pass http://81.70.253.100:8080/websocket; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } }
-p 80:80 -p 81:81 -p 82:82
docker run --name nginx --restart=always -p 80:80 -p 81:81 -p 82:82 -p 443:443 -d -v /usr/local/nginx/nginx.conf:/etc/nginx/nginx.conf -v /usr/local/vue:/usr/local/vue -v /usr/local/upload:/usr/local/upload nginx
//修改nginx配置,在不能重启的情况下,可以无需重新启动Docker容器即可重新加载新配置。Nginx可以hot-reload配置而不重新启动。
//查询nginx所在容器id:docker ps -a
docker ps -a
//测试nginx配置
docker exec 容器id nginx -t
//重新加载nginx配置
docker exec 容器id nginx -s reload
docker search minio
docker pull minio/minio
docker run -p 9000:9000 -p 9090:9090 --net=host --name minio -d --restart=always -e "MINIO_ACCESS_KEY=minioadmin" -e "MINIO_SECRET_KEY=minioadmin" -v/usr/local/minio/data:/data -v /usr/local/minio/config:/root/.minio minio/minio server /data --console-address ":9090" -address ":9000"
consoleAdmin
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。