例子:
我们需要创建一个 docker-compose.yml 文件,在该文件中配置运行容器需要的命令和参数。
san@sandeMac-mini test % docker-compose --version
Docker Compose version v2.26.1-desktop.1
san@sandeMac-mini test % docker-compose up -d
WARN[0000] /Users/san/test/docker-compose.yaml: `version` is obsolete
[+] Running 1/1
! webapp Warning pull access denied for hello, repository does not exist or may require 'do... 24.2s
[+] Building 4.1s (9/9) FINISHED docker:desktop-linux
=> [webapp internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 169B 0.0s
=> [webapp internal] load metadata for docker.io/library/golang:latest 0.0s
=> [webapp internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [webapp 1/4] FROM docker.io/library/golang:latest 0.0s
=> [webapp internal] load build context 0.0s
=> => transferring context: 1.20kB 0.0s
=> CACHED [webapp 2/4] WORKDIR /app 0.0s
=> [webapp 3/4] COPY . . 0.0s
=> [webapp 4/4] RUN go build -o main . 3.9s
=> [webapp] exporting to image 0.2s
=> => exporting layers 0.1s
=> => writing image sha256:0ecc754bd36c2f12b62884d11c1c0f76d0e298de4e9c82e8022da6189ad6a9f9 0.0s
=> => naming to docker.io/library/hello:1.0.0 0.0s
[+] Running 2/2
✔ Network test_default Created 0.0s
✔ Container hello Started
我鼠标位于第一个代码块的最后一个字符 Docker Compose version v2.26.1-desktop.1
,此时我想着第一个代码块下面创建新的文字,点键盘方向键下,直接进入的是第二个代码块,而不是在第一个代码块与第二个代码块之间产生新的空间。使用过其他的 markdown 相关软件都是可以的
想要实现后的效果说明
san@sandeMac-mini test % docker-compose --version
Docker Compose version v2.26.1-desktop.1
在编写完 docker-compose.yml 文件之后,我们可以使用 docker-compose 命令行工具管理容器。
san@sandeMac-mini test % docker-compose up -d
WARN[0000] /Users/san/test/docker-compose.yaml: `version` is obsolete
[+] Running 1/1
! webapp Warning pull access denied for hello, repository does not exist or may require 'do... 24.2s
[+] Building 4.1s (9/9) FINISHED docker:desktop-linux
=> [webapp internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 169B 0.0s
=> [webapp internal] load metadata for docker.io/library/golang:latest 0.0s
=> [webapp internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [webapp 1/4] FROM docker.io/library/golang:latest 0.0s
=> [webapp internal] load build context 0.0s
=> => transferring context: 1.20kB 0.0s
=> CACHED [webapp 2/4] WORKDIR /app 0.0s
=> [webapp 3/4] COPY . . 0.0s
=> [webapp 4/4] RUN go build -o main . 3.9s
=> [webapp] exporting to image 0.2s
=> => exporting layers 0.1s
=> => writing image sha256:0ecc754bd36c2f12b62884d11c1c0f76d0e298de4e9c82e8022da6189ad6a9f9 0.0s
=> => naming to docker.io/library/hello:1.0.0 0.0s
[+] Running 2/2
✔ Network test_default Created 0.0s
✔ Container hello Started
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于