记录一下docker desktop windows安装,容器安装等

安装包下载

https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe
 

 

 
 

docker应用管理工具,选择性安装
https://www.rainbond.com/docs/quick-start/quick-install
https://www.bilibili.com/video/BV1MZ4y1b7wW/?p=2&spm_id_from=pageDriver&vd_source=b44203991b8ee2e43d764088707392f5

Rabbitmq 安装命令
 

2. 进入RabbitMQ容器

docker pull rabbitmq:management
docker run -d --hostname rabbitmq --name rabbitmq -p 15672:15672 -p 5672:5672 rabbitmq:management
 
docker exec -it rabbitmq bash

3. 使用rabbitmqctl命令创建用户

rabbitmqctl add_user yaya yaya
rabbitmqctl set_user_tags yaya administrator
rabbitmqctl set_permissions -p / yaya ".*" ".*" ".*"
 
REDIS
docker pull redis
docker run -d --name myredis -p 6379:6379 redis --requirepass "123456"

nacos

mysql8 配置,解决分组和日期不对问题,etc/my.cnf
在mysqld 下面,加,不要在最后一行加
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
default-time-zone=+08:00


FROM openjdk:8
ADD target/*.jar /root/app.jar
ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8
ENV JAVA_HOME /opt/java
ENV PATH $JAVA_HOME/bin:$PATH
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["java", "-jar", "-server", "-Xmx1024m", "-Xms1024m","-Xmn384m", "-XX:MaxDirectMemorySize=2048m", "-XX:SurvivorRatio=8", "-Dreactor.netty.pool.leasingStrategy=lifo", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/logs/dump", "-Dspring.profiles.active=dev", "-Dspring.cloud.nacos.discovery.server-addr=8.8.9.248:8848", "-Dspring.cloud.nacos.config.server-addr=8.8.9.248:8848","-Dspring.cloud.nacos.discovery.ip=8.8.9.248", "-Xdebug","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5000", "/root/app.jar"]

 

windows docker desktop乱码:

ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8
项目启动参数包括。nacos参数,不需要可以去掉或者修改
FROM openjdk:8
ADD target/*.jar /root/app.jar
ENV LANG C.UTF-8
ENV LANGUAGE zh_CN:en
ENV LC_ALL C.UTF-8
ENV JAVA_HOME /opt/java
ENV PATH $JAVA_HOME/bin:$PATH
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["java", "-jar", "-server", "-Xmx1024m", "-Xms1024m","-Xmn384m", "-XX:MaxDirectMemorySize=2048m", "-XX:SurvivorRatio=8", "-Dreactor.netty.pool.leasingStrategy=lifo", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/logs/dump", "-Dspring.profiles.active=dev", "-Dspring.cloud.nacos.discovery.server-addr=8.8.9.248:8848", "-Dspring.cloud.nacos.config.server-addr=8.8.9.248:8848","-Dspring.cloud.nacos.discovery.ip=8.8.9.248", "-Xdebug","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5000", "/root/app.jar"]

 

 

Nginx etc/nginx/conf.d/default.conf, etc/nginx/nginx.conf
server {
    listen       20005;
    server_name  localhost;

    client_max_body_size 100M;

    set $cache max-age=86400;
    location / {
        root   /usr/share/nginx/html;
        #解决页面刷新404问题
        try_files $uri $uri/ @router;
        index  index.html index.htm;

        add_header Access-Control-Allow-Origin *;
        add_header Cache-Control $cache;
        add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
        add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
 
        if ($request_method = 'OPTIONS') {
            return 204;
        }
    }

    # 由于路由的资源不一定是真实的路径,无法找到具体文件
    # 所以需要将请求重写到 index.html 中,然后交给真正的 Vue 路由处理请求资源
    location @router {
        add_header Cache-Control $cache;
        rewrite ^.*$ /index.html last;
    }
 
    # 关键步骤,这里表示将所有的 http://172.18.1.82:80/api/ 开头的请求都转发到下面 proxy_pass 指定的链接中
    # 为了防止在访问页面时请求就被 Nginx 代理转发,这里需要更具体的配置,才能和前端访问请求区分开
    location /api/ {
        # 后端的真实接口
        proxy_pass http://localhost:8000/;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   Cookie $http_cookie;
        # for Ajax
        #fastcgi_param HTTP_X_REQUESTED_WITH $http_x_requested_with;
        proxy_set_header HTTP-X-REQUESTED-WITH $http_x_requested_with;
        proxy_set_header HTTP_X_REQUESTED_WITH $http_x_requested_with;
        proxy_set_header x-requested-with $http_x_requested_with;
        client_max_body_size 100m;
        client_body_buffer_size 128k;
        proxy_connect_timeout 90;
        proxy_send_timeout 90;
        proxy_read_timeout 90;
        proxy_buffer_size 128k;
        proxy_buffers 32 32k;
        proxy_busy_buffers_size 128k;
        proxy_temp_file_write_size 128k;
    }
}
user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    # 开启和关闭gzip模式
    gzip on;
    # gizp压缩起点,文件大于1k才进行压缩
    gzip_min_length 1k;
    # 设置压缩所需要的缓冲区大小,以4k为单位,如果文件为7k则申请2*4k的缓冲区
    gzip_buffers 4 16k;
    # 设置gzip压缩针对的HTTP协议版本
    gzip_http_version 1.0;
    # gzip 压缩级别,1-9,数字越大压缩的越好,也越占用CPU时间
    gzip_comp_level 5;
    # 进行压缩的文件类型
    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x    -httpd-php application/javascript application/json;
    # 是否在http header中添加Vary: Accept-Encoding,建议开启
    gzip_vary on;

    include /etc/nginx/conf.d/*.conf;
}


拉去前端文件放Nginx里面
源:/root/home/web
目的:C:\Users\admin\Desktop\yaya_nginx\web
各个文件夹dist解压到dist:比如
C:\Users\admin\Desktop\yaya_nginx\nginx\nginx-erp\dist.zip 压缩文件
C:\Users\admin\Desktop\yaya_nginx\nginx\nginx-erp\dist 文件夹
 
NGINX批量启动脚本和停止
@echo off
set nginx_path=C:\Users\admin\Desktop\yaya_nginx\nginx

cd "%nginx_path%\nginx-scm
start  "nginx" "%nginx_path%\nginx-scm\nginx.exe"
cd ../nginx-ums
start  "nginx" "%nginx_path%\nginx-ums\nginx.exe"
cd ../nginx-erp
start  "nginx" "%nginx_path%\nginx-erp\nginx.exe"
cd ../nginx-mes
start  "nginx" "%nginx_path%\nginx-mes\nginx.exe"
cd ../nginx-plm
start  "nginx" "%nginx_path%\nginx-plm\nginx.exe"

timeout 10

@echo off
taskkill /f /im nginx.exe
exit
posted @ 2024-04-27 10:59  _Phoenix  阅读(130)  评论(0编辑  收藏  举报