我正在使用jenkins构建docker容器并将完成的映像发送到AWS S3存储桶。
我正在尝试将从Github中提取的文件放到docker镜像上,然后将其打包到docker镜像中。
目前我有jenkins完成git pull并构建容器,但我无法将它复制到容器中。我收到这个错误:
Building in workspace /var/lib/jenkins/jobs/copy-to-docker/workspace
[workspace] $ /bin/sh -xe /tmp/hudson5108979322433439821.sh
+ docker cp /var/lib/jenkins/jobs/Move git pull files to docker/workspace/html/:index.html
+ :/var/lib/docker/containers
/tmp/hudson5108979322433439821.sh: 2: /tmp/hudson5108979322433439821.sh: :/var/lib/docker/containers: not found
docker: "cp" requires 2 arguments.
See 'docker cp --help'.
Usage: docker cp [OPTIONS] CONTAINER:PATH LOCALPATH|-
docker cp [OPTIONS] LOCALPATH|- CONTAINER:PATH
Copy files/folders between a container and the local filesystem
Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.
Build step 'Execute shell' marked build as failure
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Finished: FAILURE`
我还想更改容器ID和容器名称,但是我查看了docker文档并且我找不到这样做的方法吗?
答案 0 :(得分:0)
我对Jenkins没有任何经验,但对于docker特有的功能,我可以尝试帮助你。
要将文件复制到正在运行的泊坞窗容器,您需要执行以下操作:
\b
请参阅:Copying files from host to Docker container
如果要在创建docker镜像时复制它,则需要执行以下操作(在Dockerfile中):
docker cp foo.txt mycontainer:/foo.txt
docker cp mycontainer:/foo.txt foo.txt
请参阅:https://docs.docker.com/engine/reference/builder/
至于容器ID,我认为你不能直接设置这些,并且你不应该真的需要在docker中,你可以在每个实例中用ID代替容器的名称。处理过。
如果要重命名要使用的docker 正在运行的 docker容器:
COPY \$foo /quux # COPY $foo /quux
请参阅:https://docs.docker.com/engine/reference/commandline/rename/
否则,您可以使用以下命令启动具有特定名称的容器:
docker rename [OPTIONS] OLD_NAME NEW_NAME
希望这会有所帮助:)