dockerでビルドしたいのですができません
go
1package main 2 3import ( 4 "fmt" 5 "log" 6 "net/http" 7) 8 9func main(){ 10 http.HandleFunc("/",func(w http.ResponseWriter, r *http.Request){ 11 log.Println("received request") 12 fmt.Fprintf(w, "Hello Docker!!") 13 }) 14 15 log.Println("start server") 16 server := &http.Server{Addr: ":8000"} 17 if err := server.ListenAndServer(); err != nil { 18 log.Println(err) 19 }
Dockerfile
1FROM golang:1.13 2 3RUN mkdir /echo 4COPY main.go /echo 5 6CMD ["go", "run", "/echo/main.go"] 7
command
1user@Users-MacBook-Pro-70 2.1.2 % docker image build -t example/echo:latest . 2[+] Building 1.3s (7/7) FINISHED 3 => [internal] load build definition from Dockerfile 0.0s 4 => => transferring dockerfile: 36B 0.0s 5 => [internal] load .dockerignore 0.0s 6 => => transferring context: 2B 0.0s 7 => [internal] load metadata for docker.io/library/golang:1.13 1.1s 8 => [internal] load build context 0.0s 9 => => transferring context: 2B 0.0s 10 => CANCELED [1/3] FROM docker.io/library/golang:1.13@sha256:8ebb6d5a48deef738381b56b1d4cd33d99a5d608e0d03c 0.0s 11 => => resolve docker.io/library/golang:1.13@sha256:8ebb6d5a48deef738381b56b1d4cd33d99a5d608e0d03c5fe8dfa3f 0.0s 12 => => sha256:8ebb6d5a48deef738381b56b1d4cd33d99a5d608e0d03c5fe8dfa3f68d41a1f8 2.36kB / 2.36kB 0.0s 13 => => sha256:24bd48a274920bf47ead96c5a2db8e6a3fbe26e8ae27557c2caa9aeae562a998 1.79kB / 1.79kB 0.0s 14 => => sha256:d6f3656320fe38f736f0ebae2556d09bf3bde9d663ffc69b153494558aec9a79 6.19kB / 6.19kB 0.0s 15 => CACHED [2/3] RUN mkdir /echo 0.0s 16 => ERROR [3/3] COPY main.go /echo 0.0s 17------ 18 > [3/3] COPY main.go /echo: 19------ 20failed to compute cache key: "/main.go" not found: not found
goのファイルの名前はmain.goです
goもdockerもテキストの内容をまる写ししたはずです
どのような原因が考えられますか?
追記
command
1user@Users-MacBook-Pro-70 2.1.2 % ls -la 2total 16 3-rw-r--r-- 1 user staff 347 Oct 7 23:35 main.go 4drwxr-xr-x@ 4 user staff 128 Oct 7 23:35 . 5drwxr-xr-x@ 4 user staff 128 Oct 7 23:35 .. 6-rw-r--r-- 1 user staff 89 Oct 7 19:15 Dockerfile
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/10/09 11:00
2021/10/09 11:40
2021/10/09 15:46