Closed DrWeiZhou closed 7 years ago
You better ask in the docker mailing list. You are trying to copy a file from one container to another using docker cp and a local file reference , no idea if docker supports it
Thanks to reply. In the script, I just copy the file from the Jenkins container to the local machine. It does work but copy as a directory. I did not copy a file from a container to another one. Besides, I run a similar script in the local Jenkins rather than in a Jenkins container, it does work. Therefore, the problem should be related to the Jenkins container.
You are running jenkins in a container, so when you run
sudo docker cp jenkins:/var/jenkins_home/workspace/rpm/target/rpm.war /home/
it is copying the war into the container under /home/rpm.war
Then you run a container mounting /home/rpm.war as a volume
sudo docker run --name tomcat --link mysql:mysql -p 80:8080 -v /home/rpm.war:/usr/local/tomcat/webapps/rpm.war --rm -d tomcat:7.0.75-jre7
but docker daemon runs in the host, and in the host there is no /home/rpm.war
Thanks very much for your reply and you are right.
I found the rpm.war in the /home of the container. Is there any way I can copy the rpm.war to the local machine by a command run in the container? Thanks for your help.
I solved this problem by mounting a volume to a container's directory and copying the rpm.war to the mounted directory. Thanks for the help:)
@DrWeiZhou , looks like you have installed docker in docker container. How did you do that? I am getting a ulimit error when I try to run docker command in a docker container
Since there is no problem when I run the script in real Jenkins and in local host machine, I think it is a problem related to the Jenkins Image.
I am running a Jenkins server in a docker container.
I started the Jenkins container by the following command:
In a Jenkins job, I want to copy the builded .war to the local machine (i.e. out of the docker container) and to launch another Tomcat docker server. However, the file in the docker file become a directory after I use the command
docker cp
, that is, the rpm.war file become a rpm.war directory and nothing in it. How should I solve this problem, thanks very much.Below are my script post in the
Execute shell
in a jenkins job.Here are the Jenkins console:
And the rpm.war is a directory and nothing in it!
Besides, the script can run ok in the local machine and command `docker cp' really copy file as file, rather than a directory.
Furthermore, I use the similar script runing in a real Jenkins rather than in a container, it does work and the file is copied as a file. The similar script is
At last, my jenkins Dockerfile: