1. golang:latest base image mkdir gotest touch main.go touch Dockerfile 1. Example code package main import ( "fmt" "log" "net/http" ) func main() { http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { fmt.Fprint(writer, "Hello World") }) fmt.Println("3000!!") log.Fatal(http.ListenAndServe(":3000", nil)) } 2. Dockerfile configuration #Source image FROM golang:latest #Set the working directory WORKDIR $GOPATH/src/github.com/gotest #Add the server's go project code to the docker container ADD . $GOPATH/src/github.com/gotest #go build executable file RUN go build . #Expose port EXPOSE 3000 #Finally run the docker command ENTRYPOINT ["./gotest"] 3. Packaging the image docker build -t gotest .
2. alpine:latest base image
#Source image FROM alpine:latest #Set the working directory WORKDIR $GOPATH/src/github.com/common #Add the server's go project code to the docker container ADD . $GOPATH/src/github.com/common #Expose port EXPOSE 3002 #Finally run the docker command ENTRYPOINT ["./common"] Packaging image docker build -t common . This is the end of this article about the implementation of two basic images for Docker deployment of Go. For more relevant content about Docker deployment of Go images, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Vue implements the magnifying glass effect of tab switching
>>: Vue Basics Introduction: Vuex Installation and Use
Introduction to jQuery The jQuery library can be ...
When we add borders to table and td tags, double ...
First, let's explain the network setting mode...
CentOS official website address https://www.cento...
Preparation Windows Server 2008 R2 Enterprise (2....
Introduction react-i18next is a powerful internat...
1. When you open the web page, 503 service unavai...
When laying out the page, in order to give users ...
Communication between containers 1. Network shari...
Table of contents 1. Install JDK 2. Install Jenki...
Docker Installation curl -fsSL https://get.docker...
nohup Command When using Unix/Linux, we usually w...
Alibaba Cloud Server cannot connect to FTP FileZi...
In order to enhance the ability to write JavaScri...
I just tried it on IE6, and it does show the toolb...