跳到主要内容
赞助推荐 Claude Team 合租,少折腾账号
>80aj_
工程实践

Kubernetes 入门(一):核心概念与架构概览

3 分钟阅读阅读(389)
赞助推荐 团队协作里的 AI 办公工作台

Build Helloworld.go

package main

import (
    "fmt"
    "log"
    "net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
    log.Println("received request from", r.RemoteAddr, r.URL.Path[1:])
    var welcome = r.URL.Path[1:]
    if len(welcome) == 0 {
        welcome = "World"
    }
    fmt.Fprintf(w, "Hello, %s! ", welcome)
}

func main() {
    http.HandleFunc("/", handler)
    log.Println("starting server on port 9000")
    log.Fatal(http.ListenAndServe(":9000", nil))
}

Make Dockerfile

FROM golang:latest

# 将工作目录设置为 /app
WORKDIR /app

# 将当前目录下的所有内容复制到 /app 下
COPY . /app

# 允许宿主机访问容器的 8000 端口
EXPOSE 9000

# 设置容器进程为:go run helloworld.go
CMD go run helloworld.go

Build Image

docker build -t helloworld:1.0 .

Start container

docker run -d --name myhello -p 9000:9000 helloworld:1.0
赞助推荐 一键部署 AI 大模型
赞助推荐 一键部署 AI 大模型
赞(0)
未经允许不得转载:80aj » Kubernetes 入门(一):核心概念与架构概览
赞助推荐 低成本上手 Claude Code 的中转选择
赞助推荐 低成本上手 Claude Code 的中转选择
赞助推荐 一键部署 AI 大模型
赞助推荐 一键部署 AI 大模型