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.
docker exec -it app-server bashin a new terminal, thencd /opt/appand thenlsand let us know what the result is?docker runis started from inside the container, the$PWDis resolved as/probably, or/rootso you are either mounting/app:/opt/appor/root/app:/opt/appwhich results in being empty. You can validate this: 1)docker psto get the list of running containers, get its id 2) docker inspect [id_here] then look forMounts