Last active
May 14, 2019 02:25
-
-
Save doggy8088/644dc9e5b6dd702805cafa2acb592056 to your computer and use it in GitHub Desktop.
迎接嶄新的Windows容器叢集架構:Kubernetes - 演講過程示範的命令 ( #Study4Love ) - http://bit.ly/study4love-k8s-windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM 建立容器 | |
docker run --name myc -it microsoft/windowsservercore cmd | |
REM 列出容器 (執行中的容器) | |
docker ps | |
REM 列出容器 (所有的的容器) | |
docker ps -a | |
REM 啟動容器 | |
docker start myc | |
REM 在容器中執行任意程式 | |
docker exec -it myc powershell | |
REM 停止容器 | |
docker stop myc | |
REM 刪除容器 | |
docker rm myc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM 搜尋容器映像 ( Docker Hub ) | |
docker search KEYWORD | |
REM 列出所有容器映像 | |
docker images | |
REM 建立容器映像 | |
docker run --name myc -it microsoft/windowsservercore cmd | |
docker commit myc willh/myc | |
docker rm myc | |
docker images | |
docker run --name myc --rm -it willh/myc cmd | |
REM 建立容器映像 ( 從 Dockerfile 建立 ) | |
docker build -t willh/myc:Release-1 . | |
REM 標記指定容器映像 | |
docker tag willh/myc willh/myc:0.1 | |
REM 刪除容器映像 | |
docker rmi willh/myc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM 建立 IIS 容器 | |
docker run --name iis1 -p 80:80 -d microsoft/iis | |
REM 查詢 IIS 所在 IP 地址 | |
docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" iis1 | |
REM 複製網頁檔案進去 | |
docker cp miniasp/. iis1:/Inetpub/wwwroot/ | |
REM 停止 IIS 容器 | |
docker stop iis1 | |
REM 刪除 IIS 容器 | |
docker rm iis1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM 建立 SQL Server 容器 | |
docker run -d --name mydb -p 1433:1433 -e sa_password=my_VERYPa00w0rd -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer | |
REM 透過 sqlcmd 連入資料庫 (信任式連線) | |
docker exec -it mydb sqlcmd -S. -E | |
1> CREATE DATABASE ContosoUniversity | |
docker exec -it mydb sqlcmd -S. -E -Q "CREATE DATABASE ContosoUniversityTest" | |
REM 透過 sqlcmd 連入資料庫 (帳號登入) | |
docker exec -it mydb sqlcmd -S. -Usa | |
REM 強迫刪除 SQL Server 容器 | |
docker rm -f mydb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM 建立 IIS 容器 | |
docker run --name asp1 -p 80:80 -d microsoft/aspnet:4.6.2 | |
REM 複製 ASP.NET MVC 網頁檔案進去 | |
REM https://code.msdn.microsoft.com/ASPNET-MVC-Application-b01a9fe8 | |
docker cp ContosoUniversity/. asp1:/Inetpub/wwwroot/ | |
REM 停止 IIS 容器 | |
docker stop asp1 | |
REM 刪除 IIS 容器 | |
docker rm asp1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM 建立 SQL Server 容器 | |
docker run -d --name mydb -p 1433:1433 -e sa_password=my_VERYPa00w0rd -e ACCEPT_EULA=Y -v C:\Projects\mydb:C:\mydb\ -e attach_dbs="[{'dbName':'ContosoUniversity2','dbFiles':['C:\\mydb\\ContosoUniversity2.mdf','C:\\mydb\\ContosoUniversity2_log.ldf']}]" microsoft/mssql-server-windows-developer | |
REM 查看 SQL Server 啟動紀錄 | |
docker logs mydb | |
REM 重新啟動 ASP.NET 網站 (如果 SQL Server 重啟會導致內部 IP 改變) | |
docker restart asp1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM 透過 Dockerfile 建立容器映像 | |
docker build -t willh/miniasp . | |
REM 重新執行網站 | |
docker run --name asp1 -p 80:80 -d willh/miniasp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM 列出 K8S 所有 Namespaces | |
kubectl get namespaces | |
REM 列出 K8S 所有 Namespaces (簡寫) | |
kubectl get ns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
REM 列出 K8S 所有 Pods | |
kubectl get pods --all-namespaces | |
kubectl get pods --namespace=default | |
kubectl get pods | |
kubectl get pods --show-labels | |
REM 列出 K8S 所有 Pods (簡寫) | |
kubectl get po | |
kubectl get po --all-namespaces | |
kubectl get po --namespace=kube-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
REM 列出 K8S 所有 Deployments | |
kubectl get deployments | |
REM 列出 K8S 所有 Deployments (簡寫) | |
kubectl get deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
REM 列出 K8S 所有 Services | |
kubectl get services | |
REM 列出 K8S 所有 Services (簡寫) | |
kubectl get svc | |
REM 列出 K8S 所有 Services (簡寫+寬欄位) | |
kubectl get svc -o wide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
REM 調整 Deployment 的規模 | |
kubectl scale --replicas=3 deploy/iis-deployment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM microsoft/iis | |
WORKDIR /Inetpub/wwwroot | |
COPY miniasp/. . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment