FROM golang:1.11
RUN mkdir /app
WORKDIR /app
ADD . $SRC_DIR
EXPOSE 8000
ENTRYPOINT ["./service"]
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"./service\": permission denied".
sudo docker run --name service_container -d -p 8000:8000 service_image
sudo chmod 775 service
RUN chmod +x ./service
FROM alpine
ADD ./service /
RUN chmod +x /service
EXPOSE 8000
ENTRYPOINT ["./service"]
RUN chmod +x /service
, как вы советовали. Контейнер создался, но не запустился. Выдает теперь такую ошибку:standard_init_linux.go:178: exec user process caused "exec format error"
linux/amd64
. Могу ошибаться, возможно вместо FROM alpine
нужно указать что-то другое. Что думаете на счет этого? GCC
cо значением C:\TDM-GCC-64
set GOOS=linux
set GOARCH=amd64
go build -v -o questionnaire -ldflags="-extld=$GCC"
arch
(должна выдать x86_64 для amd64)docker pull karalabe/xgo-latest
go get github.com/karalabe/xgo
xgo -targets linux/amd64 .
FROM alpine
это alpine(легковесная ОС для контейнеров)FROM debian
FROM golang:1.11
RUN go get github.com/gorilla/mux && \
go get github.com/gorilla/handlers && \
go get github.com/lib/pq && \
go get github.com/joho/godotenv && \
go get github.com/jinzhu/gorm && \
go get gopkg.in/goracle.v2
ADD ./ /go/src/application
WORKDIR /go/src/application
RUN go build -o /service application
ENV PORT=8000
CMD ["/service "]
package gopkg.in/goracle.v2: unrecognized import path "gopkg.in/goracle.v2" (https fetch: Get https://gopkg.in/goracle.v2?go-get=1: proxyconnect tcp: tls: first record does not look like a TLS handshake)
The command '/bin/sh -c go get github.com/gorilla/mux && go get github.com/gorilla/handlers && go get github.com/lib/pq && go get github.com/joho/godotenv && go get github.com/jinzhu/gorm && go get gopkg.in/goracle.v2' returned a non-zero code: 1
gopkg.in/goracle.v2
. Есть ли идеи на счет этого? FROM golang:1.11
ADD ./ /go/src/application
WORKDIR /go/src/application
RUN go get ./...
RUN go build -o /service application
ENV PORT=8000
CMD ["/service"]
RUN go get ./...
все ложится:package application/database: unrecognized import path "application/database" (import path does not begin with hostname)
package application/routes: unrecognized import path "application/routes" (import path does not begin with hostname)
package application/utils: unrecognized import path "application/utils" (import path does not begin with hostname)
package application/models: unrecognized import path "application/models" (import path does not begin with hostname)
package gopkg.in/goracle.v2: unrecognized import path "gopkg.in/goracle.v2" (https fetch: Get https://gopkg.in/goracle.v2?go-get=1: proxyconnect tcp: tls: oversized record received with length 20527)
package application/controllers: unrecognized import path "application/controllers" (import path does not begin with hostname)
- application
- database
- routes
- utils
- models
- controllers
main.go
Dockerfile
https fetch: Get https://gopkg.in/goracle.v2?go-get=1: proxyconnect tcp: tls: oversized record received with length 20527
FROM golang:1.11
WORKDIR /go/src/application
ADD . .
RUN go get ./...
RUN go build -o /service .
ENV PORT=8000
CMD ["/service"]
FROM golang:1.11
RUN go get github.com/gorilla/mux && \
go get github.com/gorilla/handlers && \
go get github.com/lib/pq && \
go get github.com/joho/godotenv && \
go get github.com/jinzhu/gorm
WORKDIR /go/src/application
ADD . .
RUN go build -o /service .
ENV PORT=8000
CMD ["/service "]
FROM golang:1.11
RUN go get github.com/gorilla/mux && \
go get github.com/gorilla/handlers && \
go get github.com/lib/pq && \
go get github.com/joho/godotenv && \
go get github.com/jinzhu/gorm
WORKDIR /go/src/application
ADD . .
ENV PORT=8000
CMD ["ls", "-la", "/go/src/application"]
drwxr-xr-x. 10 root root 222 Mar 12 14:07 .
drwxrwxrwx. 4 root root 43 Mar 12 14:07 ..
-rw-r--r--. 1 root root 326 Mar 7 11:18 .env
drwxr-xr-x. 7 root root 150 Mar 12 09:16 .git
-rw-r--r--. 1 root root 12 Mar 3 15:09 .gitignore
drwxr-xr-x. 4 root root 192 Mar 12 09:16 .idea
-rw-r--r--. 1 root root 804 Mar 12 2019 Dockerfile
-rw-r--r--. 1 root root 2603 Mar 12 05:14 README.md
drwxr-xr-x. 2 root root 173 Mar 12 09:16 controllers
drwxr-xr-x. 2 root root 44 Mar 12 09:16 database
-rw-r--r--. 1 root root 1951 Mar 7 11:32 main.go
drwxr-xr-x. 2 root root 93 Mar 12 09:16 models
-rw-r--r--. 1 root root 16507975 Mar 12 08:47 application
drwxr-xr-x. 2 root root 23 Mar 12 09:16 routes
drwxr-xr-x. 2 root root 22 Mar 12 09:16 utils
drwxr-xr-x. 3 root root 22 Mar 12 09:16 vendor
Step 11/13 : RUN go build -o /application .
---> Running in 98a045250847
main.go:9:2: cannot find package "application/database" in any of:
/go/src/application/vendor/application/database (vendor tree)
/usr/local/go/src/application/database (from $GOROOT)
/go/src/application/database (from $GOPATH)
main.go:10:2: cannot find package "application/routes" in any of:
/go/src/application/vendor/application/routes (vendor tree)
/usr/local/go/src/application/routes (from $GOROOT)
/go/src/application/routes (from $GOPATH)
main.go:11:2: cannot find package "application/utils" in any of:
/go/src/application/vendor/application/utils (vendor tree)
/usr/local/go/src/application/utils (from $GOROOT)
/go/src/application/utils (from $GOPATH)
FROM golang:1.11
RUN go get github.com/gorilla/mux && \
go get github.com/gorilla/handlers && \
go get github.com/lib/pq && \
go get github.com/joho/godotenv && \
go get github.com/jinzhu/gorm
WORKDIR /go/src/application
ADD . .
RUN go build -o /service ./...
ENV PORT=8000
CMD ["/service "]
main.go:9:2: cannot find package "application/database" in any of:
/go/src/application/vendor/application/database (vendor tree)
/usr/local/go/src/application/database (from $GOROOT)
/go/src/application/database (from $GOPATH)
main.go:10:2: cannot find package "application/routes" in any of:
/go/src/application/vendor/application/routes (vendor tree)
/usr/local/go/src/application/routes (from $GOROOT)
/go/src/application/routes (from $GOPATH)
main.go:11:2: cannot find package "application/utils" in any of:
/go/src/application/vendor/application/utils (vendor tree)
/usr/local/go/src/application/utils (from $GOROOT)
/go/src/application/utils (from $GOPATH)
controllers/factor.go:10:2: cannot find package "application/models" in any of:
/go/src/application/vendor/application/models (vendor tree)
/usr/local/go/src/application/models (from $GOROOT)
/go/src/application/models (from $GOPATH)
vendor/gopkg.in/goracle.v2/conn.go:33:2: cannot find package "github.com/pkg/errors" in any of:
/go/src/application/vendor/github.com/pkg/errors (vendor tree)
/usr/local/go/src/github.com/pkg/errors (from $GOROOT)
/go/src/github.com/pkg/errors (from $GOPATH)
routes/routes.go:5:2: cannot find package "application/controllers" in any of:
/go/src/application/vendor/application/controllers (vendor tree)
/usr/local/go/src/application/controllers (from $GOROOT)
/go/src/application/controllers (from $GOPATH)
xgo -targets linux/amd64 .
docker pull karalabe/xgo-latest
xgo -targets linux/amd64 .
Выдал такой message:Checking docker installation...
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24302
Built: Fri Mar 23 08:31:36 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server: Docker Engine - Community
Engine:
Version: 18.09.3
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 774a1f4
Built: Thu Feb 28 06:40:51 2019
OS/Arch: linux/amd64
Experimental: false
Checking for required docker image karalabe/xgo-latest... found.
Cross compiling application...
docker: Error response from daemon: invalid mode: /build.
See 'docker run --help'.
2019/03/12 21:09:13 Failed to cross compile package: exit status 125.
docker: Error response from daemon: invalid mode: /build.