0

I am new to the concept of Docker. In my office server we have installed Docker and running the Jenkins images as containers.

We want to run the below command in the Jenkinsfile in a process to create the Jenkins pipeline.

docker run --rm -p 8080:8080 -v $PWD/app:/opt/app --name=app-server App 

The problem is face is the volumes are not mounting in the /opt/app from the $PWD/app (which is the volume of the Jenkins container).

I have app.txt file in the $PWD/app. After running the above command it should present in the /opt/app, but the folder is empty.

Because of this the configuration files are missing in the app-server container volume. Error config files are missing is happening.

What is the reason for this problem. Why the files in the $PWD/app are not mounting to the /opt/app folder?

Point to consider:

docker run command is running in the Jenkins container.

The command on top is running prefect when the jenkins is running locally,not as docker container.

9
  • Can you do docker exec -it app-server bash in a new terminal, then cd /opt/app and then ls and let us know what the result is? Commented Sep 17, 2019 at 6:31
  • If this docker run is started from inside the container, the $PWD is resolved as / probably, or /root so you are either mounting /app:/opt/app or /root/app:/opt/app which results in being empty. You can validate this: 1) docker ps to get the list of running containers, get its id 2) docker inspect [id_here] then look for Mounts Commented Sep 17, 2019 at 6:31
  • The pipeline is executed in the workspace, the mount would be i.e. /path/to/jenkins/workspace/app:/opt/apt - if the “app” folder is in the jenkins users HOME directory then use the $HOME environment variable in the bind mount. Commented Sep 17, 2019 at 6:32
  • I did docker exec -it app-server bash in a new terminal, then cd /opt/app and then ls. The app folder is empty Commented Sep 17, 2019 at 6:34
  • $PWD is resolved to the volume of the jenkins, which is its workspace. I am mounting from /var/jenkins_home/my_pipeline_job/app:/opt/app Commented Sep 17, 2019 at 6:39

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.