0

I am new to the Jenkins and docker. I wonder if there is way to push the files from container to local. I mounted local dir to docker, but it seems all files only updated in container.

local dir: /home/xyz/ container dir: /var/jenkins_home/xyz

docker run \
  --name jenkins \
  --restart=on-failure \
  --detach \
  --network jenkins \
  --env DOCKER_HOST=tcp://docker:2376 \
  --env DOCKER_CERT_PATH=/certs/client \
  --env DOCKER_TLS_VERIFY=1 \
  --publish 8080:8080 \
  --publish 50000:50000 \
  --mount type=bind,source=/home/xyz/,target=/var/jenkins_home/xyz \
  --volume jenkins-data:/var/jenkins_home \
  --volume jenkins-docker-certs:/certs/client:ro \
  myjenkins-blueocean:2.361.3-1 
rok
  • 9,403
  • 17
  • 70
  • 126
galaxyan
  • 5,944
  • 2
  • 19
  • 43

1 Answers1

0
  • When you ran Jenkins image using --volume jenkins-data:/var/jenkins_home you used docker volumes. Docker manages the volume and you can find the exact data location by inspecting the volumes of the container.

  • When you used --mount type=bind,source=/home/xyz/,target=/var/jenkins_home/xyz you mapped the folder /var/jenkins_home/xyz from the container to folder /home/xyz/ on the docker host using bind mounts. Jenkins home data changes in the container are reflected on the host path. Create a new job and you will see its definition in jobs folder.

You should use either docker volumes or bind mounts, not both for a single data folder.

  • If you want to copy data from the container to the host use docker cp command.
rok
  • 9,403
  • 17
  • 70
  • 126