查看: 74|回复: 0

Portainer环境5分钟部署MSSQL

[复制链接]

5

主题

10

帖子

22

积分

新手上路

Rank: 1

积分
22
发表于 2023-1-12 10:23:05 | 显示全部楼层 |阅读模式
背景

用Docker运行一个MSSQL实例
微软提供了这几个版本的镜像


参考资料

Microsoft Artifact Registry
Configure and customize SQL Server Docker containers - SQL Server
配置文件

version: '3'

services:
  mssql2022:
    image: mcr.microsoft.com/mssql/server:2022-latest
    container_name: mssql2022
    restart: always
    ports:
      - 1433:1433
    environment:
      - MSSQL_SA_PASSWORD=yourpassword
      - ACCEPT_EULA=Y
      - MSSQL_PID=Express
    volumes:
      - /data/mssql2022/log:/var/opt/mssql/log
      - /data/mssql2022/data:/var/opt/mssql/data
      - /data/mssql2022/secrets:/var/opt/mssql/secrets
      - /data/mssql2022/backup:/var/opt/mssql/backup
    networks:
      erixProd:
        ipv4_address: 172.20.0.9

networks:
  erixProd:
    external: true注意事项

要配置的不多,配置文件按照你自己的需求改,注意点如下:
需要至少2G内存
这里为了备份方便,加了个backup目录,请先手动创建好。我设为777是方便传文件。
宿主机的几个目录需要把uid/pid设为10001


MSSQL_PID意思是不同的版本,这里放了免费的Express版。以下是区别

  • Developer : This will run the container using the Developer Edition (this is the default if no MSSQL_PID environment variable is supplied)
  • Express : This will run the container using the Express Edition
  • Standard : This will run the container using the Standard Edition
  • Enterprise : This will run the container using the Enterprise Edition
  • EnterpriseCore : This will run the container using the Enterprise Edition Core <valid product id> : This will run the container with the edition that is associated with the PID
设置的SA密码要符合要求
端口改了好像没法访问
启动及测试



自动生成的数据库文件



启动后的内存使用



Restore Database报错



Restore Files and Filegroups成功



Shrink Database



Backup Database


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表