1、假设所有容器都在Docker下。
2、Seata的目录在Docker/Seata路径下。
3、创建目录结构
mkdir -p /Docker/Seata/{seata-server,jars} cd /Docker/Seata
4、从镜像提取 resources 和 libs
# ★ cp 目标写的是父目录 seata-server/(不是 seata-server/resources): # docker cp 会把源目录整个拷到目标目录"里面"——目标若写成已存在的 # seata-server/resources,就会得到 seata-server/resources/resources,多套一层! docker create --name seata-tmp apache/seata-server:2.2.0 docker cp seata-tmp:/seata-server/resources seata-server/ docker cp seata-tmp:/seata-server/libs seata-server/ docker rm seata-tmp
5、添加缺少的驱动
cd /Docker/Seata/seata-server/libs wget https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/8.0.33/mysql-connector-j-8.0.33.jar
6、修改 seata-server/resources/application.yml
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # 解决无限报错的BUG "seata.store.db..vgroup-table": vgroup_table server: port: 7091 spring: application: name: seata-server logging: config: classpath:logback-spring.xml file: path: ${log.home:${user.home}/logs/seata} extend: logstash-appender: destination: 127.0.0.1:4560 kafka-appender: bootstrap-servers: 127.0.0.1:9092 topic: logback_to_logstash console: user: username: seata password: seata seata: config: # support: nacos, consul, apollo, zk, etcd3 type: file registry: # support: nacos, eureka, redis, zk, consul, etcd3, sofa type: nacos nacos: application: seata-server server-addr: nacos:8848 # ★ 原生版是 192.168.20.139:8848 group: SEATA_GROUP # nacos 容器在同一 Docker 网络里, namespace: "" # 用容器名互访(容器名不同就换掉 nacos) cluster: default username: nacos # ★ 改成你 Nacos 控制台的实际登录账号密码 password: nacos store: # support: file 、 db 、 redis 、 raft mode: db db: datasource: druid db-type: mysql driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://192.168.20.139:3306/seata?useSSL=true&serverTimezone=Asia/Shanghai # ★ 保持宿主机 IP!MySQL 在宿主机原生部署, # 不在 Docker 网络里,不能用容器名 user: seata password: seata min-conn: 5 max-conn: 30 global-table: global_table branch-table: branch_table lock-table: lock_table distributed-lock-table: distributed_lock query-limit: 100 max-retry-size: 10 # server: # service-port: 8091 #If not configured, the default is '${server.port} + 1000' security: secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017 tokenValidityInMilliseconds: 1800000 csrf-ignore-urls: /metadata/v1/** ignore: urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/version.json,/health,/error,/vgroup/v1/**
7、修改docker-compose.yml文件
services: nacos: image: nacos/nacos-server:v2.5.3 container_name: nacos ports: - "8848:8848" - "9848:9848" environment: MODE: standalone SPRING_DATASOURCE_PLATFORM: mysql MYSQL_SERVICE_HOST: 192.168.20.139 MYSQL_SERVICE_PORT: 3306 MYSQL_SERVICE_DB_NAME: nacos MYSQL_SERVICE_USER: nacos MYSQL_SERVICE_PASSWORD: nacos MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai NACOS_AUTH_ENABLE: "true" NACOS_AUTH_TOKEN: "tSZiqFk+O6P1oUQffkWgdLHjEVNkTDLQcwDqDbB9bsE=" # ⚠️ 生产环境必须更换 NACOS_AUTH_IDENTITY_KEY: nacos # ⚠️ 生产环境更换 key NACOS_AUTH_IDENTITY_VALUE: nacos # ⚠️ 生产环境更换 value volumes: - ./nacos-server2.5.3/data:/home/nacos/data - ./nacos-server2.5.3/logs:/home/nacos/logs restart: always networks: - timeless minio: image: minio/minio:latest container_name: minio restart: unless-stopped ports: - "9000:9000" # S3 API - "9001:9001" # Web 控制台 environment: MINIO_ROOT_USER: admin MINIO_ROOT_PASSWORD: adminTimeless # 至少 8 位,务必修改 volumes: - /MinIO/Data:/data - /MinIO/Conf/certs:/root/.minio/certs # 可选:HTTPS 证书目录,不用可删 command: server /data --console-address ":9001" healthcheck: test: ["CMD", "mc", "ready", "local"] interval: 30s timeout: 5s retries: 3 start_period: 10s logging: driver: json-file options: max-size: "50m" max-file: "3" networks: - timeless seata-server: depends_on: nacos: condition: service_started image: apache/seata-server:2.2.0 container_name: seata-server environment: - SEATA_IP=192.168.20.139 # ★★ 最容易踩的坑,见下方说明 - SEATA_PORT=8091 # 遗留写法,2.x 实际不生效(端口由 yaml 的 # seata.server.service-port 决定),删掉也无影响 - STORE_MODE=db - TZ=Asia/Shanghai ports: - "8091:8091" # TC 事务端口(TM/RM 客户端连这个) - "7091:7091" # Web Console(2.2.0 内嵌,浏览器访问) volumes: - ./Seata/seata-server/resources:/seata-server/resources # 配置(4.4 改好的) - ./Seata/seata-server/libs:/seata-server/libs # 依赖(4.3 加好驱动的) restart: on-failure # ★★ Nacos 跨 compose 没法 depends_on,靠失败重试兜底 networks: - timeless # ★ 换成 139 上 Nacos 的实际网络名 networks: timeless: name: timeless driver: bridge
8、浏览器验证
http://192.168.20.139:7091/#/transaction/list
Ubuntu24.04利用Docker部署Seata2.2
| Title | Ubuntu24.04利用Docker部署Seata2.2 |
|---|---|
| Framework | Docker |
| User | wy8817399@vip.qq.com |
| Id | 94 |
| Created | 8/22/26, 9:45 PM |
| Modified | 8/22/26, 9:45 PM |
| Published | Yes |
Content