我使用以下命令在Docker容器中安装了一个Gitlab:
sudo docker run --detach \
--hostname git.example.com \
--publish 443:443 --publish 80:80 --publish 2201:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
--volume /srv/gitlab/mounts:/etc/gitlab/mounts \
gitlab/gitlab-ce:latest
然后我已经安装了多个网络NTFS单元
mount.cifs -o username=gituser,password=somepassword,uid=997,gid=994 "//10.10.10.16/Git" /srv/gitlab/mounts/shared_folder
因此,我可以尝试在容器中访问此文件夹,并且可以正常工作。当我想使用像这样的后接收钩子时,问题就来了
#!/usr/bin/env bash
while read oldrev newrev ref
do
DATE=`date '+%Y-%m-%d %H:%M:%S'`;
if [[ $ref =~ .*/master$ ]];
then
echo $DATE >> logProd.txt
git --work-tree=/mnt/gitlab/shared_folder/production --git-dir=/var/opt/gitlab/git-data/repositories/repo.git checkout -f m$
echo "Master ref received. Deploying master branch to production...">> logProd.txt
fi
if [[ $ref =~ .*/desarrollo$ ]];
then
echo $DATE >> logDevelop.txt;
echo "Desarrollo ref received. Deploying develop branch to develop...">> logDevelop.txt
git --work-tree=/mnt/gitlab/shared_folder/developement--git-dir=/var/opt/gitlab/git-data/repositories/repo.git checkout -f developement
echo "Desarrollo ref received. Deploying finished">> logDevelop.txt
fi
if [[ $ref =~ .*/testing$ ]];
then
echo $DATE >> logTesting.txt;
echo "Testing ref received. Deploying testing branch to testing...">> logTesting.txt
git --work-tree=/mnt/gitlab/shared_folder/testing --git-dir=/var/opt/gitlab/git-data/repositories/repo.git checkout -f testing
echo "Testing ref received. Deploying finished">> logTesting.txt
fi
done
然后,当我推送到存储库时,我会收到多个“权限被拒绝”,尽管推送实际上已完成,但该文件夹并未被复制到NTFS文件夹。
我认为该问题与在Docker容器内执行post-receive.sh挂钩的用户的权限有关,但我尝试将文件夹更改为777权限,但没有任何效果,它们会立即返回他们以前的权限。
我尝试在NTFS内部创建一个与容器root用户共享的文件夹,它的工作原理很好,但是与git用户一起,我得到的是“错误:无法创建文件README.md:权限被拒绝”,文件。