欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Docker学习与运行(二)

程序员文章站 2022-07-12 10:03:32
...

接(一):运行hello-world

(2020-1-8 8:01:23)

Starting "default"...
(default) Check network to re-create if needed...
(default) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(default) Waiting for an IP...

右击鼠标有反应?

Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...



                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/

docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com


Start interactive shell

url:官方入门教学

Docker学习与运行(二)

aaa@qq.com MINGW64 /d/Program Files/Docker Toolbox
$ cd E:\GitProjects\Docker\doodle\cheers2019\                                                                           >
bash: cd: E:GitProjectsDockerdoodlecheers2019: No such file or directory

aaa@qq.com MINGW64 /d/Program Files/Docker Toolbox
$ cd E:\GitProjects\Docker\doodle\cheers2019
bash: cd: E:GitProjectsDockerdoodlecheers2019: No such file or directory

aaa@qq.com MINGW64 /d/Program Files/Docker Toolbox
$ cd 'E:\GitProjects\Docker\doodle\cheers2019'

aaa@qq.com MINGW64 /e/GitProjects/Docker/doodle/cheers2019 (master)
$ docker build -t gwdsss/cheers2019 .
Sending build context to Docker daemon  13.31kB
Step 1/9 : FROM golang:1.11-alpine AS builder
1.11-alpine: Pulling from library/golang
9d48c3bd43c5: Pull complete
7f94eaf8af20: Pull complete                                                                                             9fe9984849c1: Pull complete                                                                                             ec448270508e: Downloading [====>                                              ]  9.051MB/110.3MB                        65ba82af53f7: Download complete

等待.
右击可以刷新查看进度.
Docker学习与运行(二)
网络.可能炸了.等待.
16.61MB/110.3MB
(2020-1-8 8:28:27)
这么久下载了16M.想修改配置.
或者等待.

url:网速慢解答

那么(2020-1-8 8:44:08)
查看.这个文件.
Docker学习与运行(二)
看readme.md

Docker学习与运行(二)

docker run -it --rm docker/doodle:cheers

不同的说法?对比官网.是下一步.
打开Dockerfile

FROM golang:1.11-alpine AS builder
RUN apk add --no-cache git
RUN go get github.com/pdevine/go-asciisprite
WORKDIR /project
COPY cheers.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags ‘-extldflags “-static”’ -o cheers cheers.go

FROM scratch
COPY --from=builder /project/cheers /cheers
ENTRYPOINT ["/cheers"]

另外两个文件
Docker学习与运行(二)
安装提示的插件
文件一

FROM --platform=$BUILDPLATFORM golang:1.11-alpine AS builder
RUN apk add --no-cache git
RUN go get github.com/pdevine/go-asciisprite
WORKDIR /project
COPY cheers.go .

ARG TARGETOS
ARG TARGETARCH
ENV GOOS=TARGETOSGOARCH=TARGETOS GOARCH=TARGETARCH
RUN CGO_ENABLED=0 go build -a -ldflags ‘-extldflags “-static”’ -o cheers cheers.go

FROM scratch AS release-linux
COPY --from=builder /project/cheers /cheers
ENTRYPOINT ["/cheers"]

FROM mcr.microsoft.com/windows/nanoserver:1809 AS release-windows
COPY --from=builder /project/cheers /cheers.exe
ENTRYPOINT ["\cheers.exe"]

FROM release-$TARGETOS
Docker学习与运行(二)
安装
Docker学习与运行(二)
漫长的代码.
发布.等待下一篇继续写.(2020-1-8 8:59:00)
洗漱.起床.撸代码9:30-10:30