It would be good if we were able to build a standard image which could be made available through Docker Hub, rather than the current process where the image is built on the fly every time it is needed.
The main reason it is like this is that Jenkins passes the -u flag when it launches containers using the withDockerContainer step. This causes the container to run with the user and group set to that of the user Jenkins is running under on the host, in order to ensure that the file permissions on the mounted workspace volume don't cause any problems. This means that the container will generally be running as an unknown user, which works fine for many things, but unfortunately git does not work as expected unless it is running as a real user. (I think this is actually down to SSH rather than git itself.)
The second reason is that we are using "Docker in Docker" by sharing the Docker socket at /var/run/docker. This also requires the user id in the container to be that of a user on the host which has permissions to run docker.
Because of this, we are passing the uid and gid of the jenkins user on the host as build arguments to the Dockerfile.
If there were a way to avoid having to do this we could build an image and push it to Docker Hub.
It would be good if we were able to build a standard image which could be made available through Docker Hub, rather than the current process where the image is built on the fly every time it is needed.
The main reason it is like this is that Jenkins passes the -u flag when it launches containers using the withDockerContainer step. This causes the container to run with the user and group set to that of the user Jenkins is running under on the host, in order to ensure that the file permissions on the mounted workspace volume don't cause any problems. This means that the container will generally be running as an unknown user, which works fine for many things, but unfortunately git does not work as expected unless it is running as a real user. (I think this is actually down to SSH rather than git itself.)
The second reason is that we are using "Docker in Docker" by sharing the Docker socket at /var/run/docker. This also requires the user id in the container to be that of a user on the host which has permissions to run docker.
Because of this, we are passing the uid and gid of the jenkins user on the host as build arguments to the Dockerfile.
If there were a way to avoid having to do this we could build an image and push it to Docker Hub.