1.获取镜像

docker pull seataio/seata-server

2.运行容器并获取配置
为方便我们对seata配置修改我们需要先运行下seata-server,然后将配置拷贝到宿主机中,完成之后删除之前配置并通过宿主机运行容器。

## 运行容器
docker run --name seata-server -p 8091:8091 -d  seataio/seata-server:latest
## 将容器中的配置拷贝到/usr/local/seata
docker cp seata-server:/seata-server /usr/local/seata
## 完成后就会在/usr/local/seata出现容器的配置,我们现在可以将原来容器停止并删除
docker stop seata-server
docker rm seata-server

3.修改配置文件
application.yml内容:

server:
  port: 7091

spring:
  application:
    name: seata-server

logging:
  config: classpath:logback-spring.xml
  file:
    path: ${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: admin
    password: admin

seata:
  config:
    # support: nacos, consul, apollo, zk, etcd3
    type: nacos
    nacos:
      server-addr: 127.0.0.1:8848
      namespace:
      group: SEATA_GROUP
      username:
      password:
      ##if use MSE Nacos with auth, mutex with username/password attribute
      #access-key: ""
      #secret-key: ""
      data-id: seataServer.properties
  registry:
    # support: nacos, eureka, redis, zk, consul, etcd3, sofa
    type: nacos
    preferred-networks: 30.240.*
    nacos:
      application: seata-server
      server-addr: 127.0.0.1:8848
      group: SEATA_GROUP
      namespace:
      cluster: default
      username:
      password:
      ##if use MSE Nacos with auth, mutex with username/password attribute
      #access-key: ""
      #secret-key: ""
  store:
    # support: file 、 db 、 redis
    mode: file
    session:
      mode: file
    lock:
      mode: file
    file:
      dir: sessionStore
      max-branch-session-size: 16384
      max-global-session-size: 512
      file-write-buffer-cache-size: 16384
      session-reload-read-size: 100
      flush-disk-mode: async
#  server:
#    service-port: 8091 #If not configured, the default is '${server.port} + 1000'
  security:
    secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
    tokenValidityInMilliseconds: 1800000
    ignore:
      urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login

4、重新运行docker

#重启docker自动启动
docker run -d --restart always  --name  seata-server -p 8091:8091  -v /usr/local/seata:/seata-server seataio/seata-server

#重启docker手动启动
docker run -d  --name  seata-server -p 8091:8091  -v /usr/local/seata:/seata-server seataio/seata-server


在这里插入图片描述

参考文档:

docker中安装seata
linux中安装seata并集成到nacos中
Docker学习——安装Seata
docker安装seata
docker安装seata

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐