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

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

Golang docker 容器無法在 Windows Home 上啟動(dòng)

Golang docker 容器無法在 Windows Home 上啟動(dòng)

Go
慕運(yùn)維8079593 2022-07-11 15:16:57
我正在使用在 Docker 中啟用了 WSL 的 Windows Home OS。打印下面的構(gòu)建消息后docker build .SECURITY WARNING: You are building a Docker image from Windows against a non-    Windows Docker host. All files and directories added to build context will have '-rwxr-    xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.當(dāng)我嘗試運(yùn)行下面的圖像消息時(shí)打印docker run 49fee6f5a6bb -ddocker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"-d\": executable file not found in $PATH": unknown.Dockerfile 內(nèi)容如下FROM golang:alpine# Set necessary environmet variables needed for our imageENV GO111MODULE=on \    CGO_ENABLED=0 \    GOOS=linux \    GOARCH=amd64# Move to working directory /buildWORKDIR /build# Copy and download dependency using go modCOPY go.mod .COPY go.sum .RUN go mod download# Copy the code into the containerCOPY . .# Build the applicationRUN go build -o main .# Move to /dist directory as the place for resulting binary folderWORKDIR /dist# Copy binary from build to main folderRUN cp /build/main .# Export necessary portEXPOSE 3000# Command to run when starting the containerCMD ["/dist/main"]
查看完整描述

1 回答

?
LEATH

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

問題是命令的順序(很可能):


docker run -d yourcontainer應(yīng)該管用


一些不相關(guān)的建議:這是對(duì)您的 docker 文件的重寫(未經(jīng)測(cè)試)。如您所見,它更短,并且使用構(gòu)建和運(yùn)行階段。


FROM alpine:latest構(gòu)建階段使用一個(gè)更大的容器,里面有g(shù)olang 、你的代碼等。運(yùn)行容器(例如,僅使用您的代碼來強(qiáng)化 linux)。


FROM golang:alpine AS build


WORKDIR /build

ADD . /build


# Depending on the golang version GO111MODULE can be removed as env variable

RUN GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o main 


FROM alpine:latest


# Export necessary port

EXPOSE 3000

# Add  application

WORKDIR /dist

COPY --from=build /build/main /dist/main


查看完整回答
反對(duì) 回復(fù) 2022-07-11
  • 1 回答
  • 0 關(guān)注
  • 101 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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