ubuntu@shenzhen:~ $ cat hello.go
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
ubuntu@shenzhen:~ $ go build hello.go
ubuntu@shenzhen:~ $ ./hello
hello world
ubuntu@shenzhen:~ $ mkdir gohello
ubuntu@shenzhen:~ $ cp hello gohello/
ubuntu@shenzhen:~ $ cd gohello/
ubuntu@shenzhen:~/gohello $ ls
hello
ubuntu@shenzhen:~/gohello $ vim Dockerfile
ubuntu@shenzhen:~/gohello $ docker build -t myhello:latest .
Sending build context to Docker daemon 2.012MB
Step 1/3 : FROM scratch
--->
Step 2/3 : COPY hello /
---> ca4b658b1549
Step 3/3 : CMD ["/hello"]
---> Running in 2ebeeef54814
Removing intermediate container 2ebeeef54814
---> bd91ff0fe143
Successfully built bd91ff0fe143
Successfully tagged myhello:latest
ubuntu@shenzhen:~/gohello $ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
myhello latest bd91ff0fe143 4 seconds ago 2.01MB
ubuntu@shenzhen:~/gohello $ docker container run myhello
hello world
Docker自制golang版helloworld
最新推荐文章于 2022-09-10 14:33:44 发布