I am trying to connect to docker postgres database from the golang code. Command used to create the postgres container: docker run -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password –name my-postgres -p 5432:5432 postgres To create the database I run: PS C:UsersAylinDesktopfarmers> docker exec -it my-postgres bash [email protected]:/# psql -U postgres psql (13.2 (Debian 13.2-1.pgdg100+1)) Type "help" ..
Category : go
I have the following dockerfile: FROM golang:1.16.3 as compile WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . # CGO_ENABLED for static linking library RUN go env -w GOPRIVATE="github.com/<some_account>/*"; GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.version=$1 -X main.build=`date -u +%Y%m%d.%H%M%S`" -o /app/server server.go FROM scratch #WORKDIR / #FROM alpine:latest #RUN ..
I have a server code written in golang that listen to http and connecting to mongodb at localhost:27017 at my development machine and on aws ec-2 instance also the same host. All is working well when I run it via go run main.go. sudo docker build -t server /mnt/c/code/tttfm/backend/server returns => [internal] load build definition ..
command-line-arguments ./anotherruncontainer.go:38:4: cannot use portBinding (type "github.com/docker/go-connections/nat".PortMap) as type "github.com/docker/docker/vendor/github.com/docker/go-connections/nat".PortMap in field value Here is my code : package main import ( "context" "fmt" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" "github.com/docker/go-connections/nat" ) func main (){ CreateNewContainer("mar82022") } func CreateNewContainer(image string) (string, error) { cli, err := client.NewEnvClient() if err != nil { fmt.Println("Unable to create docker ..
command-line-arguments ./anotherruncontainer.go:38:4: cannot use portBinding (type "github.com/docker/go-connections/nat".PortMap) as type "github.com/docker/docker/vendor/github.com/docker/go-connections/nat".PortMap in field value Here is my code : package main import ( "context" "fmt" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" "github.com/docker/go-connections/nat" ) func main (){ CreateNewContainer("mar82022") } func CreateNewContainer(image string) (string, error) { cli, err := client.NewEnvClient() if err != nil { fmt.Println("Unable to create docker ..
I maked docker-compose for elasticsearch and mysql. All container installed "safelly" but when i try to log in to my db with adminer and try it many times i can’t and some error occured: SQLSTATE[HY000] [2002] Connection refused. I don’t know why, i tried to restart my docker and i got SQLSTATE[HY000] [2002] Host is ..
I’ve written an API in Golang, and the production image is built using a multistage Dockerx build. The output of the Dockerx build is an image that is FROM scratch, and the compiled Go executable inside of it is statically compiled (my understanding is that it wouldn’t work with FROM scratch if it were dynamically ..
I figured some strange behaviour of my program when I run it inside a Docker container: My golang code: package main import ( "fmt" "os" "path/filepath" ) func main() { fmt.Println(os.Args[0]) fmt.Println(filepath.Abs("./")) fmt.Println(os.Executable()) } My Dockerfile: FROM golang:latest as build WORKDIR /go/src/test/ COPY . . RUN go build . FROM scratch COPY –from=build /go/src/test/test /app/test ..
I’m developing a web app in gin, and I’ve installed realize as a hot reloading tool. In my local environment, realize start works fine, but when I run it in docker-compose , it says "project not found" and won’t start the server. [email protected]:/app# realize start len [0/0]0x0 [15:37:06][APP] : Watching 14 file/s 14 folder/s [15:37:06][APP] ..
Good day everyone. I’m in the middle of a task using our docker image to build go microservice. To reduce build time, keep the images under control. I expect that after downloading the golang image from the docker hub, upload it to our registry and use it in all the dockerfiles of our microservices. As ..