close

確認 docker 是否是 執行 windows containers 不是要切換成 windows containers

 

 

 

 

執行 microsoft/windowsservercore 的 cmd ....可執行代表正常

 

建立web.go
D:\GO>type web.go
package main

import(
"fmt"
"net/http"
"runtime"
)

func indexHandler( w http.ResponseWriter, r *http.Request){
fmt.Fprintf(w, "hello world, I'm running on %s with an %s CPU ", runtime.GOOS,runtime.GOARCH)

}

func main(){
http.HandleFunc("/", indexHandler)
http.ListenAndServe(":8080",nil)

}

編譯 web.go
D:\GO>go build web

建立 Dockerfile
D:\GO>type Dockerfile
FROM microsoft/windowsservercore
COPY web.exe c:\web.exe
ENTRYPOINT c:\web.exe
EXPOSE 8080

 

建立 images
D:\GO>docker build -t web .
Sending build context to Docker daemon 5.513 MB
Step 1/4 : FROM microsoft/windowsservercore
 ---> 7baaa272ad7d
Step 2/4 : COPY web.exe c:\web.exe
 ---> 3519307952d2
Removing intermediate container ee19178652f7
Step 3/4 : ENTRYPOINT c:\web.exe
 ---> Running in 54bddbeb0eac
 ---> 4c32a2b27d7f
Removing intermediate container 54bddbeb0eac
Step 4/4 : EXPOSE 8080
 ---> Running in ea8b9faee79c
 ---> 6a64853e2dcc
Removing intermediate container ea8b9faee79c
Successfully built 6a64853e2dcc

建立 CONTAINER
D:\GO>docker run -d -p 8080:8080 --name my-web-go web
f9d8d55aeba299298da3feac041afe330e8747ffb0d7742ded49449337773820

查看 docker CONTAINER IP
D:\GO>docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}"  my-web-go
172.19.51.58

 

 

建立 IIS DockerFile

FROM microsoft/iis

RUN powershell -NoProfile -Command \
    Import-module IISAdministration; \
    New-IISSite -Name "Site" -PhysicalPath C:\site -BindingInformation "*:8000:"

EXPOSE 8000

其他方式與 上面 web.go 一樣建立 CONTAINER

 

IIS 的完成後畫面

 

用 NGROK .....ngrok http 172.19.62.53:80

 

 

 

 

 

 

 

 

 

 

arrow
arrow
    文章標籤
    iis docker golang
    全站熱搜
    創作者介紹
    創作者 echochio 的頭像
    echochio

    echochio

    echochio 發表在 痞客邦 留言(0) 人氣()