折腾了一个上午,docker使用这个配置文件就可以打包镜像啦

FROM domblack/oracle-jdk8
VOLUME /tmp
COPY *.jar /tmp/
ENTRYPOINT ["java","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005","-jar","/tmp/jeewx-boot-base-system-1.0.0.jar"]
EXPOSE 8080
EXPOSE 5005

其中5005是调试用端口,然后如果想要包redis和数据库进去,可以使用docker-compose。 直接把数据库文件挂载到容器内部23333

version: '3'
services:
  redis:
    image: redis
    ports:
    - 6379:6379
  db:
    container_name: mysql-name2
    image: mysql
    volumes:
      - ./dataw:/var/lib/mysql
      - ./mysql/init:/docker-entrypoint-initdb.d
    ports:
      - "0.0.0.0:3308:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=YKY12345..


  web:
    build: .
    ports:
      - 8080:8080
    depends_on:
      - db
      - redis

[mysqld]
bind-address=0.0.0.0
user=mysql
default-storage-engine=INNODB
#character-set-server=utf8
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
[client]
#utf8mb4字符集可以存储emoji表情字符
#default-character-set=utf8
default-character-set=utf8mb4
[mysql]
#default-character-set=utf8
default-character-set=utf8mb4

use mysql;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'YKY12345..';
create database jeewxBot;

use jeewxBot;
....

最后修改:2020 年 09 月 30 日
如果觉得我的文章对你有用,请随意赞赏