"COPY plugins.txt" 在 Jenkins 在 Docker 在 Windows 失败

"COPY plugins.txt" in Jenkins in Docker in Windows failed

docker pull jenkinsci/blueocean

docker network create jenkins

docker volume create jenkins-docker-certs
docker volume create jenkins-data

docker container run --name jenkins-docker --rm --detach --privileged --network jenkins --network-alias docker --env DOCKER_TLS_CERTDIR=/certs --volume jenkins-docker-certs:/certs/client --volume jenkins-data:/var/jenkins_home docker:dind

docker container run --name jenkins-blueocean --rm --detach --network jenkins --env DOCKER_HOST=tcp://docker:2376 --env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 --volume jenkins-data:/var/jenkins_home --volume jenkins-docker-certs:/certs/client:ro --publish 1122:8080 --publish 50000:50000 jenkinsci/blueocean

那么,

//method 1, failed
FROM jenkinsci/blueocean:latest
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
////////////////////////////////////////////////////////////////////
Step 2/3 : COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
COPY failed: stat /var/lib/docker/tmp/docker-builder945145338/plugins.txt: no such file or directory
////////////////////////////////////////////////////////////////////

//method 2, failed
FROM jenkinsci/blueocean:latest
COPY plugins /var/jenkins_home/plugins/

//method 3, warning and plugins still not include
FROM jenkinsci/blueocean:latest
COPY . /var/jenkins_home/plugins/
////////////////////////////////////////////////////////////////////
A@pc2 MINGW64 /f/jenkins_blueocean $ docker build -t my_custom_jenkins . Sending build context to Docker daemon 2.048kB Step 1/2 : FROM jenkinsci/blueocean:latest ---> 69b6d837d67b Step 2/2 : COPY . /var/jenkins_home/ ---> b1bf0ef60bff Successfully built b1bf0ef60bff Successfully tagged my_custom_jenkins:latest SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
////////////////////////////////////////////////////////////////////

我在 (DockerToolbox-19.03.1.exe)Docker Quickstart Terminal & Windows PowerShell(Admin) 中尝试了上面的 COPY cmd,都失败了.. . 错误信息是这样的:

Step 2/3 : COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
COPY failed: stat /var/lib/docker/tmp/docker-builder945145338/plugins.txt: no such file or directory

我想在Windows中安装Jenkins和Docker中需要的插件,然后保存Jenkins&all the plugins use Docker,以便使用Jenkins&all the plugins in Docker另一台离线电脑。

您将 plugins.txt 文件存储在哪里?

它应该与 Dockerfile 存在于同一文件夹中。