golang编译和docker执行

栏目: Go · 发布时间: 7年前

内容简介:1.源码dockerfile2.源码编译在mac环境需要交叉编译

1.源码

package main

import (
    "fmt"
    "net/http"
)

func main() {
    http.HandleFunc("/", home)
    http.ListenAndServe(":80", nil)
}

func home(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "welcome to golang world")
}

dockerfile

FROM daocloud.io/library/centos
USER root
RUN mkdir /app
WORKDIR /app
ADD . /app
EXPOSE 80
CMD ["chmod +x helloworld"]
CMD ["./helloworld"]

2.源码编译在mac环境需要交叉编译

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o helloworld helloworld.go

3.docker执行需要暴露端口

docker run -p 801:80  helloworld

以上所述就是小编给大家介绍的《golang编译和docker执行》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Beginning ARKit for iPhone and iPad

Beginning ARKit for iPhone and iPad

Wallace Wang / Apress / 2018-11-5 / USD 39.99

Explore how to use ARKit to create iOS apps and learn the basics of augmented reality while diving into ARKit specific topics. This book reveals how augmented reality allows you to view the screen on ......一起来看看 《Beginning ARKit for iPhone and iPad》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具