我正在尝试使用 https://gitlab.com 构建 Windows 容器,但我没有发现这是否受支持。
我用一个非常简单的 Dockerfile 做了一个测试:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
CMD echo "Hello World from Windows"
使用 .gitlab-ci.yml
image: docker
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
windows:
stage: build
script:
- docker build -t ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_SLUG} .
- docker push ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_SLUG}
它失败了:
image operating system "windows" cannot be used on this platform
ERROR: Job failed: exit code 1
找gitlab-runner的文档,好像支持https://docs.gitlab.com/runner/executors/#selecting-the-executor .
有没有办法从在线服务构建 Windows 容器?
最佳答案
自 January 2020可以使用 Windows Shared Runners (beta) 使用在线服务构建 Windows 容器。 .
Today, we are happy to announce that Windows Shared Runners hosted by GitLab is available in beta. As we are starting to roll out this important service to our community, we invite you to help shape the direction of CI/CD tooling for the Windows ecosystem on GitLab.com
例如,使用以下 .gitlab-ci.yml
windows:
stage: build
tags:
- shared-windows
- windows
- windows-1809
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_SLUG} .
- docker push ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_SLUG}
用一个简单的DockerfileFROM mcr.microsoft.com/windows/servercore:ltsc2019
CMD echo "Hello World from Windows"
管道执行 result关于docker - gitlab ci 无法构建 windows 容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54380804/