日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

在 Docker 里运行 Microsoft SQL 服务器

發布時間:2023/12/19 数据库 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在 Docker 里运行 Microsoft SQL 服务器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

鏈接:https://developers.sap.com/tutorials/cp-kyma-mssql-deployment.html

參考代碼:https://github.com/SAP-samples/kyma-runtime-extension-samples

本地路徑:C:\Code\referenceCode\SAP Kyma教程例子

This sample provides the MS SQL database configured with a sample DemoDB database which contains one Orders table populated with two rows of sample data.

這個例子展示了如何創建名為 DemoDB 的MSSQL 數據庫,以及名為 Orders 的數據庫表,以及兩行測試數據。

The app/setup.sql file handles the generation of the database, table, and data.

app 文件夾下的 setup.sql 負責創建數據庫,數據庫表和測試數據。

Within the app/init-db.sh file, you can also configure the database user and password.

init-db.sh 文件用于配置數據庫用戶名和密碼。

docker 文件夾

  • FROM:The FROM instruction initializes a new build stage and sets the Base Image for subsequent instructions. As such, a valid Dockerfile must start with a FROM instruction. The image can be any valid image – it is especially easy to start by pulling an image from the Public Repositories.

Dockerfile 用于創建 docker 鏡像。最后一行命令,執行 app 文件夾下面的 entrypoint.sh 文件。

Build the Docker image

根據 Dockerfile 構建一個鏡像:

進入如下文件夾:

C:\Code\referenceCode\SAP Kyma教程例子\database-mssql

執行命令行:

docker build -t i042416/mssql -f docker/Dockerfile .

注意,因為基于的鏡像名稱為 microsoft/mssql-server-linux, 故這個命令應該在 linux 操作系統里完成:

鏡像成功制作完畢:

docker 鏡像制作完畢后,上傳到 docker hub:

docker push i042416/mssql

上傳成功:

本地運行這個鏡像:

sudo docker run -e ACCEPT_EULA=Y -e SA_PASSWORD=Yukon900 -p 1433:1433 --name sql1 -d i042416/mssql

進入鏡像內部,打開 bash shell:

docker exec -it sql1 “bash”

Start the sqlcmd tool, which allows you to run queries against the database, by running this command: /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P Yukon900

輸入如下 query 命令:

1> USE DemoDB 2> SELECT * FROM ORDERS 3> GO

結果:成功讀取到兩條訂單數據:

在 Docker 內部的 /usr/src/app 文件夾下,確實發現了我制作 docker 鏡像時的文件:

Microsoft SQL 服務器,安裝在 /opt 目錄下:

更多Jerry的原創文章,盡在:“汪子熙”:

總結

以上是生活随笔為你收集整理的在 Docker 里运行 Microsoft SQL 服务器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。