第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

CURL 在 Docker 映像中不起作用 [無(wú)法訪問(wèn) Docker 映像中的主機(jī)]

CURL 在 Docker 映像中不起作用 [無(wú)法訪問(wèn) Docker 映像中的主機(jī)]

Go
開(kāi)心每一天1111 2022-05-18 13:48:40
碼頭工人文件# Start from the latest golang base imageFROM golang:latest# Add Maintainer InfoLABEL maintainer="Sumit Thakur <sumitthakur@yahoo.com>"# Set the Current Working Directory inside the containerWORKDIR /app# Copy go mod and sum filesCOPY go.mod go.sum ./# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changedRUN go mod download# Copy the source from the current directory to the Working Directory inside the containerCOPY . .# Build the Go appRUN go build -o testapp myapplication.go testapp.go# Expose port 50051 / for internal comunication ENV PORT 50051RUN echo $PORTEXPOSE ${PORT}# Command to run the executableCMD ["./testapp"]構(gòu)建 Docker 文件docker build -t testapp  -f Dockerfile .這是完美的工作運(yùn)行 Docker 文件docker run -d -p 50051:50051 testapp這也可以正常工作我檢查正在運(yùn)行的容器docker ps這會(huì)給我CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                      NAMES57cd3c01bcda        testapp           "./testapp"       2 seconds ago       Up 2 seconds        0.0.0.0:50051->50051/tcp   gracious_bhaskara當(dāng)我檢查網(wǎng)絡(luò)檢查時(shí)docker network inspect bridge
查看完整描述

3 回答

?
SMILET

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超4個(gè)贊

從評(píng)論中的討論來(lái)看,問(wèn)題似乎與https握手有關(guān)。

一個(gè)簡(jiǎn)單的解決方案是使用以下 URL 查詢(xún)服務(wù):

curl -H "Content-type:application/json" -X GET 'https://localhost:50051/testapp/v1/order' -v -k

使用-k,您將忽略HTTPS驗(yàn)證。

注意:我已將 URL 從更改httphttps.


查看完整回答
反對(duì) 回復(fù) 2022-05-18
?
守候你守候我

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個(gè)贊

從容器內(nèi)部,您需要偵聽(tīng)所有接口,而不是 localhost 或環(huán)回接口。網(wǎng)絡(luò)是在 docker 中命名的,因此您不僅可以獲得一個(gè)新的私有 ip,還可以獲得容器內(nèi)部一個(gè)無(wú)法從外部訪問(wèn)的單獨(dú)環(huán)回接口。為此,請(qǐng)更改:

http.ListenAndServe("localhost:50051", headersOk)

到:

http.ListenAndServe(":50051", headersOk)


查看完整回答
反對(duì) 回復(fù) 2022-05-18
?
哆啦的時(shí)光機(jī)

TA貢獻(xiàn)1779條經(jīng)驗(yàn) 獲得超6個(gè)贊

上提供的代碼main.go不會(huì)啟動(dòng) TLS,因此請(qǐng)停止使用 curl 來(lái)卷曲https,它將無(wú)法正常工作。卷曲http會(huì)起作用


package main


import (

    "io"

    "net/http"


    "github.com/gorilla/handlers"

)


func main() {

    http.HandleFunc("/testapp/v1/order", testHandler)

    headersOk := handlers.AllowedHeaders([]string{""})

    http.ListenAndServe(":50051", headersOk)

}

func testHandler(w http.ResponseWriter, r *http.Request) {

    io.WriteString(w, "Heyyy!")

}

該命令openssl s_client https://localhost:50051/testapp/v1/order -connect localhost:50051向您確認(rèn)您請(qǐng)求的端口上不存在 TLS


很多評(píng)論確認(rèn) usinghttps不相關(guān),再次在您的代碼上未激活 TLS


curl -H "Content-type:application/json" -X GET 'http://localhost:50051/testapp/v1/order'作品。再次確認(rèn) 不使用 TLS


結(jié)論:


https當(dāng)您的代碼上未激活 TLS 時(shí),不要嘗試 curl


查看完整回答
反對(duì) 回復(fù) 2022-05-18
  • 3 回答
  • 0 關(guān)注
  • 180 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)