在 Windows 主机上使用 Docker 设置 Gitlab,共享文件夹问题
Setting up Gitlab using Docker on Windows host, issue with shared folders
TLDR;
有谁知道如何解决 "Failed asserting that ownership of "/var/opt/gitlab/git-data" was git" 错误?
背景:
我想在 WindowsServer2012R2 运行 Docker 工具箱上设置 Gitlab Docker,版本 17.04.0-ce,内部版本 4845c56。
Issue/Question
服务器D盘共享文件夹无法正常运行。我读到我需要将文件夹添加到 VirtualBox VM,这是我通过 VB GUI 中的 settings/shared 文件夹菜单完成的。我为路径 "D:\data\gitlab" 设置了一个名称 "gitlab",然后检查了自动挂载、永久化并将其设置为完全访问权限。
我启动了 docker 机器和 运行 "docker-machine ssh $machine-name"。我注意到没有 /media 目录,所以我在主目录 (/home/docker/gitlab) 中添加了一个文件夹,然后使用我在几个论坛中找到的以下命令挂载了共享文件夹:
sudo mount -t vboxsf gitlab /home/docker/gitlab
此时我可以将文件添加到 Windows 主机目录或 Docker VM,它似乎工作正常并且显示了测试文件。
现在,当我启动 Gitlab Docker 图像时,我使用从他们的文档中修改的以下命令:
docker run --detach --hostname gitlab.example.com --publish 80:80 --name gitlab --volume /home/docker/gitlab:/etc/gitlab:Z --volume /home/docker/gitlab/logs:/var/log/gitlab:Z --volume /home/docker/gitlab/data:/var/opt/gitlab:Z gitlab/gitlab-ce
现在我知道它似乎正在写入共享驱动器,因为生成了所有这些文件,但几秒钟后它崩溃了,我收到以下错误日志。
错误日志:
Thank you for using GitLab Docker Image!
Current version: gitlab-ce=9.3.6-ce.0
Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:
docker exec -it gitlab vim /etc/gitlab/gitlab.rb
docker restart gitlab
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
If this container fails to start due to permission problems try to fix it by executing:
docker exec -it gitlab update-permissions
docker restart gitlab
Installing gitlab.rb config...
Generating ssh_host_rsa_key...
Generating public/private rsa key pair.
Your identification has been saved in /etc/gitlab/ssh_host_rsa_key.
Your public key has been saved in /etc/gitlab/ssh_host_rsa_key.pub.
The key fingerprint is:
SHA256:GyFlf9tl7ZuEbuE+dwZUYiyahdsRzpC1T7kwyUvoD+o root@gitlab.example.com
The key's randomart image is:
+---[RSA 2048]----+
| o .+oo |
| o .o*+o+.o|
| . . o*@+oo+|
| . o+o.Oo= |
| S o o++..|
| + oo + o|
| o .+ + |
| . o. .o|
| E .o..|
+----[SHA256]-----+
Generating ssh_host_ecdsa_key...
Generating public/private ecdsa key pair.
Your identification has been saved in /etc/gitlab/ssh_host_ecdsa_key.
Your public key has been saved in /etc/gitlab/ssh_host_ecdsa_key.pub.
The key fingerprint is:
SHA256:Kb99jG8EtMuTSdIuqBT3GLeD1D0wwTEcQhKgVJUlBjs root@gitlab.example.com
The key's randomart image is:
+---[ECDSA 256]---+
| .o+=*=+=+ |
|.. oo..=.. |
|. E . * . |
| o + +.B |
| +.BS* * |
| . +o= B . |
| . . .o = |
| . o. + |
| . .+. |
+----[SHA256]-----+
Generating ssh_host_ed25519_key...
Generating public/private ed25519 key pair.
Your identification has been saved in /etc/gitlab/ssh_host_ed25519_key.
Your public key has been saved in /etc/gitlab/ssh_host_ed25519_key.pub.
The key fingerprint is:
SHA256:lVxpu0UoyNPWVY6D9c+m/bUTyvKP6vuR4cTOYwQ0j+U root@gitlab.example.com
The key's randomart image is:
+--[ED25519 256]--+
| . o +.=o..|
| +.=o@o.+ |
| o+=.Eo o|
| . + .o.|
| S B +|
| B o= |
| .Oo +|
| ..o+.+|
| .+*+.oo|
+----[SHA256]-----+
Preparing services...
Starting services...
Configuring GitLab package...
/opt/gitlab/embedded/bin/runsvdir-start: line 24: ulimit: pending signals: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
Configuring GitLab...
================================================================================
Error executing action `run` on resource 'ruby_block[directory resource: /var/opt/gitlab/git-data]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Failed asserting that ownership of "/var/opt/gitlab/git-data" was git
---- Begin output of set -x && [ "$(stat --printf='%U' $(readlink -f /var/opt/gitlab/git-data))" = 'git' ] ----
STDOUT:
STDERR: + readlink -f /var/opt/gitlab/git-data
+ stat --printf=%U /var/opt/gitlab/git-data
+ [ UNKNOWN = git ]
---- End output of set -x && [ "$(stat --printf='%U' $(readlink -f /var/opt/gitlab/git-data))" = 'git' ] ----
Ran set -x && [ "$(stat --printf='%U' $(readlink -f /var/opt/gitlab/git-data))" = 'git' ] returned 1
Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:124:in `validate_command'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:112:in `block in validate'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:111:in `each_index'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:111:in `validate'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:87:in `validate!'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:35:in `block (3 levels) in from_file'
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb
26: ruby_block "directory resource: #{params[:path]}" do
27: block do
28: # Ensure the directory exists
29: storage_helper.ensure_directory_exists(params[:path])
30:
31: # Ensure the permissions are set
32: storage_helper.ensure_permissions_set(params[:path])
33:
34: # Error out if we have not achieved the target permissions
35: storage_helper.validate!(params[:path])
36: end
37: not_if { storage_helper.validate(params[:path]) }
38: end
39: end
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:26:in `block in from_file'
ruby_block("directory resource: /var/opt/gitlab/git-data") do
params {:path=>"/var/opt/gitlab/git-data", :owner=>"git", :group=>nil, :mode=>"0700", :name=>"/var/opt/gitlab/git-data"}
action [:run]
retries 0
retry_delay 2
default_guard_interpreter :default
block_name "directory resource: /var/opt/gitlab/git-data"
declared_type :ruby_block
cookbook_name "gitlab"
recipe_name "gitlab-shell"
block #<Proc:0x000000054a99a8@/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:27>
not_if { #code block }
end
Platform:
---------
x86_64-linux
有谁知道如何解决 "Failed asserting that ownership of "/var/opt/gitlab/git-data" was git" 错误?我对 Docker/setting up Gitlab 还是有些陌生,所以我很可能忽略了一些简单的事情。我花了几个小时谷歌搜索这个,似乎其他人也有很多问题让共享文件夹从 Windows 使用 Docker 工具箱工作,所以希望这也能帮助其他人。
背景
对于我们这些困在没有本地 docker 的世界的人来说,一个解决方案(也许不是最好的)是使用 vdi 驱动器和共享文件夹。 vdi 驱动器可以放在我们想要的驱动器上(如果您不想使用 C 驱动器,这很重要)并且用于允许 Gitlab docker 能够 chown 任何它想要的东西,所以这就是我们将存储持久卷。缺点是 vdi 不像简单的共享文件夹那样透明,因此对于备份,共享文件夹有点麻烦 easier/transparent.
免责声明
我不是这方面的专家,所以请谨慎对待我所说的话。
要执行的步骤
在您喜欢的任何驱动器上创建新的 vdi 驱动器和共享文件夹
- 关闭您要用于 gitlab 的 docker 机器
- 在 virtualbox 中进入 docker 机器上的设置,然后是 Storage,然后单击 Add Hard Disk 图标, 然后 创建新磁盘
- Select VDI(VirtualBox 磁盘映像) 并单击 下一步
- Select 动态分配然后点击下一步
- Select 通过单击带有绿色胡萝卜符号的文件夹来存储 vdi 的名称和位置,然后 select vdi 可以增长到的最大大小,然后单击 创建
- 现在在设置菜单中,切换到共享文件夹并单击添加新共享文件夹图标
- 创建一个 gitlabbackups 文件夹到任何你想要的地方然后 select Auto-mount 和 Make永久
现在分区并格式化驱动器
- Start/enter docker 机器(在命令提示符下使用 VBox window 或
docker-machine ssh <your docker machine name>
)
- 运行
fdisk -l
列出可用的驱动器,如果你只安装了一个额外的 vdi 驱动器,你应该看到类似 /dev/sdb
- 接下来的步骤是不可逆,所以请自行决定执行:输入命令
fdisk /dev/sdb
然后n
创建新分区,p
对于小学,1
- 现在格式化新分区(您可能还需要 sudo):
mkfs.ext4 /dev/sdb1
运行 docker 在第二个 vdi 上有永久卷,在共享文件夹中有备份
示例 Dockerfile:
FROM gitlab/gitlab-ce:latest
RUN apt-get update
RUN apt-get install -y cron
# Add a cron job to backup everyday
RUN echo "0 5 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create STRATEGY=copy CRON=1" | crontab -
# For an unknown reason, the cron job won't actually run unless cron is restarted
CMD service cron restart && \
/assets/wrapper
样本docker-compose.yml:
version: "3.0"
services:
gitlab:
build: .
restart: always
ports:
- "80:80"
volumes:
# These volumes are on the vdi we created above
- "/mnt/sdb1/etc/gitlab/:/etc/gitlab"
- "/mnt/sdb1/var/log/gitlab:/var/log/gitlab"
- "/mnt/sdb1/var/opt/gitlab:/var/opt/gitlab"
# This volume sits in the shared folder defined above
- "/gitlabbackups:/var/opt/gitlab/backups"
cap_add:
# These seem to be necessary for the mounted drive to work properly
# https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
- SYS_ADMIN
- DAC_READ_SEARCH
因为自动安装 vdi 似乎有问题,使用启动脚本,例如(假设您使用 D 驱动器,只需根据需要替换 <...> 中的任何内容),示例 run.bat:
@cd /d D:\<path to docker-compose.yml, assuming it's on the D drive>
@docker-machine start <docker machine name>
@FOR /f "tokens=*" %%i IN ('docker-machine env <docker machine name>') DO @%%i
@docker-machine ssh <docker machine name> sudo mount /dev/sdb1 /mnt/sdb1
@docker-compose build
@docker-compose up -d
@REM If the docker machine was completely off, running only 'docker-compose up -d' will
@REM not mount the volumes properly. Stopping and restarting the container results in
@REM the volumes mounting properly.
@docker stop <gitlab container name>
@docker start <gitlab container name>
@pause
注意:gitlab容器名称可以通过运行宁docker-compose up
一次,然后docker ps -a
查看,但通常遵循约定<directory compose file is in>_<name in the compose file, e.g. gitlab here>_1
假设一切顺利并且您根据自己的情况更改了上面 <...> 中的内容,您应该能够 运行 批处理文件并启动 gitlab 并且 运行 以这种方式将所有内容存储在备用驱动器上,vdi 中的持久工作文件(以绕过 VBox POSIX 限制),以及透明存储在共享文件夹中的备份。
希望这可以帮助其他无法访问本地 docker 的可怜人。
TLDR;
有谁知道如何解决 "Failed asserting that ownership of "/var/opt/gitlab/git-data" was git" 错误?
背景:
我想在 WindowsServer2012R2 运行 Docker 工具箱上设置 Gitlab Docker,版本 17.04.0-ce,内部版本 4845c56。
Issue/Question
服务器D盘共享文件夹无法正常运行。我读到我需要将文件夹添加到 VirtualBox VM,这是我通过 VB GUI 中的 settings/shared 文件夹菜单完成的。我为路径 "D:\data\gitlab" 设置了一个名称 "gitlab",然后检查了自动挂载、永久化并将其设置为完全访问权限。
我启动了 docker 机器和 运行 "docker-machine ssh $machine-name"。我注意到没有 /media 目录,所以我在主目录 (/home/docker/gitlab) 中添加了一个文件夹,然后使用我在几个论坛中找到的以下命令挂载了共享文件夹:
sudo mount -t vboxsf gitlab /home/docker/gitlab
此时我可以将文件添加到 Windows 主机目录或 Docker VM,它似乎工作正常并且显示了测试文件。
现在,当我启动 Gitlab Docker 图像时,我使用从他们的文档中修改的以下命令:
docker run --detach --hostname gitlab.example.com --publish 80:80 --name gitlab --volume /home/docker/gitlab:/etc/gitlab:Z --volume /home/docker/gitlab/logs:/var/log/gitlab:Z --volume /home/docker/gitlab/data:/var/opt/gitlab:Z gitlab/gitlab-ce
现在我知道它似乎正在写入共享驱动器,因为生成了所有这些文件,但几秒钟后它崩溃了,我收到以下错误日志。
错误日志:
Thank you for using GitLab Docker Image!
Current version: gitlab-ce=9.3.6-ce.0
Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:
docker exec -it gitlab vim /etc/gitlab/gitlab.rb
docker restart gitlab
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
If this container fails to start due to permission problems try to fix it by executing:
docker exec -it gitlab update-permissions
docker restart gitlab
Installing gitlab.rb config...
Generating ssh_host_rsa_key...
Generating public/private rsa key pair.
Your identification has been saved in /etc/gitlab/ssh_host_rsa_key.
Your public key has been saved in /etc/gitlab/ssh_host_rsa_key.pub.
The key fingerprint is:
SHA256:GyFlf9tl7ZuEbuE+dwZUYiyahdsRzpC1T7kwyUvoD+o root@gitlab.example.com
The key's randomart image is:
+---[RSA 2048]----+
| o .+oo |
| o .o*+o+.o|
| . . o*@+oo+|
| . o+o.Oo= |
| S o o++..|
| + oo + o|
| o .+ + |
| . o. .o|
| E .o..|
+----[SHA256]-----+
Generating ssh_host_ecdsa_key...
Generating public/private ecdsa key pair.
Your identification has been saved in /etc/gitlab/ssh_host_ecdsa_key.
Your public key has been saved in /etc/gitlab/ssh_host_ecdsa_key.pub.
The key fingerprint is:
SHA256:Kb99jG8EtMuTSdIuqBT3GLeD1D0wwTEcQhKgVJUlBjs root@gitlab.example.com
The key's randomart image is:
+---[ECDSA 256]---+
| .o+=*=+=+ |
|.. oo..=.. |
|. E . * . |
| o + +.B |
| +.BS* * |
| . +o= B . |
| . . .o = |
| . o. + |
| . .+. |
+----[SHA256]-----+
Generating ssh_host_ed25519_key...
Generating public/private ed25519 key pair.
Your identification has been saved in /etc/gitlab/ssh_host_ed25519_key.
Your public key has been saved in /etc/gitlab/ssh_host_ed25519_key.pub.
The key fingerprint is:
SHA256:lVxpu0UoyNPWVY6D9c+m/bUTyvKP6vuR4cTOYwQ0j+U root@gitlab.example.com
The key's randomart image is:
+--[ED25519 256]--+
| . o +.=o..|
| +.=o@o.+ |
| o+=.Eo o|
| . + .o.|
| S B +|
| B o= |
| .Oo +|
| ..o+.+|
| .+*+.oo|
+----[SHA256]-----+
Preparing services...
Starting services...
Configuring GitLab package...
/opt/gitlab/embedded/bin/runsvdir-start: line 24: ulimit: pending signals: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
Configuring GitLab...
================================================================================
Error executing action `run` on resource 'ruby_block[directory resource: /var/opt/gitlab/git-data]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Failed asserting that ownership of "/var/opt/gitlab/git-data" was git
---- Begin output of set -x && [ "$(stat --printf='%U' $(readlink -f /var/opt/gitlab/git-data))" = 'git' ] ----
STDOUT:
STDERR: + readlink -f /var/opt/gitlab/git-data
+ stat --printf=%U /var/opt/gitlab/git-data
+ [ UNKNOWN = git ]
---- End output of set -x && [ "$(stat --printf='%U' $(readlink -f /var/opt/gitlab/git-data))" = 'git' ] ----
Ran set -x && [ "$(stat --printf='%U' $(readlink -f /var/opt/gitlab/git-data))" = 'git' ] returned 1
Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:124:in `validate_command'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:112:in `block in validate'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:111:in `each_index'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:111:in `validate'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:87:in `validate!'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:35:in `block (3 levels) in from_file'
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb
26: ruby_block "directory resource: #{params[:path]}" do
27: block do
28: # Ensure the directory exists
29: storage_helper.ensure_directory_exists(params[:path])
30:
31: # Ensure the permissions are set
32: storage_helper.ensure_permissions_set(params[:path])
33:
34: # Error out if we have not achieved the target permissions
35: storage_helper.validate!(params[:path])
36: end
37: not_if { storage_helper.validate(params[:path]) }
38: end
39: end
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:26:in `block in from_file'
ruby_block("directory resource: /var/opt/gitlab/git-data") do
params {:path=>"/var/opt/gitlab/git-data", :owner=>"git", :group=>nil, :mode=>"0700", :name=>"/var/opt/gitlab/git-data"}
action [:run]
retries 0
retry_delay 2
default_guard_interpreter :default
block_name "directory resource: /var/opt/gitlab/git-data"
declared_type :ruby_block
cookbook_name "gitlab"
recipe_name "gitlab-shell"
block #<Proc:0x000000054a99a8@/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:27>
not_if { #code block }
end
Platform:
---------
x86_64-linux
有谁知道如何解决 "Failed asserting that ownership of "/var/opt/gitlab/git-data" was git" 错误?我对 Docker/setting up Gitlab 还是有些陌生,所以我很可能忽略了一些简单的事情。我花了几个小时谷歌搜索这个,似乎其他人也有很多问题让共享文件夹从 Windows 使用 Docker 工具箱工作,所以希望这也能帮助其他人。
背景
对于我们这些困在没有本地 docker 的世界的人来说,一个解决方案(也许不是最好的)是使用 vdi 驱动器和共享文件夹。 vdi 驱动器可以放在我们想要的驱动器上(如果您不想使用 C 驱动器,这很重要)并且用于允许 Gitlab docker 能够 chown 任何它想要的东西,所以这就是我们将存储持久卷。缺点是 vdi 不像简单的共享文件夹那样透明,因此对于备份,共享文件夹有点麻烦 easier/transparent.
免责声明
我不是这方面的专家,所以请谨慎对待我所说的话。
要执行的步骤
在您喜欢的任何驱动器上创建新的 vdi 驱动器和共享文件夹
- 关闭您要用于 gitlab 的 docker 机器
- 在 virtualbox 中进入 docker 机器上的设置,然后是 Storage,然后单击 Add Hard Disk 图标, 然后 创建新磁盘
- Select VDI(VirtualBox 磁盘映像) 并单击 下一步
- Select 动态分配然后点击下一步
- Select 通过单击带有绿色胡萝卜符号的文件夹来存储 vdi 的名称和位置,然后 select vdi 可以增长到的最大大小,然后单击 创建
- 现在在设置菜单中,切换到共享文件夹并单击添加新共享文件夹图标
- 创建一个 gitlabbackups 文件夹到任何你想要的地方然后 select Auto-mount 和 Make永久
现在分区并格式化驱动器
- Start/enter docker 机器(在命令提示符下使用 VBox window 或
docker-machine ssh <your docker machine name>
) - 运行
fdisk -l
列出可用的驱动器,如果你只安装了一个额外的 vdi 驱动器,你应该看到类似 /dev/sdb - 接下来的步骤是不可逆,所以请自行决定执行:输入命令
fdisk /dev/sdb
然后n
创建新分区,p
对于小学,1
- 现在格式化新分区(您可能还需要 sudo):
mkfs.ext4 /dev/sdb1
运行 docker 在第二个 vdi 上有永久卷,在共享文件夹中有备份
示例 Dockerfile:
FROM gitlab/gitlab-ce:latest
RUN apt-get update
RUN apt-get install -y cron
# Add a cron job to backup everyday
RUN echo "0 5 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create STRATEGY=copy CRON=1" | crontab -
# For an unknown reason, the cron job won't actually run unless cron is restarted
CMD service cron restart && \
/assets/wrapper
样本docker-compose.yml:
version: "3.0"
services:
gitlab:
build: .
restart: always
ports:
- "80:80"
volumes:
# These volumes are on the vdi we created above
- "/mnt/sdb1/etc/gitlab/:/etc/gitlab"
- "/mnt/sdb1/var/log/gitlab:/var/log/gitlab"
- "/mnt/sdb1/var/opt/gitlab:/var/opt/gitlab"
# This volume sits in the shared folder defined above
- "/gitlabbackups:/var/opt/gitlab/backups"
cap_add:
# These seem to be necessary for the mounted drive to work properly
# https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
- SYS_ADMIN
- DAC_READ_SEARCH
因为自动安装 vdi 似乎有问题,使用启动脚本,例如(假设您使用 D 驱动器,只需根据需要替换 <...> 中的任何内容),示例 run.bat:
@cd /d D:\<path to docker-compose.yml, assuming it's on the D drive>
@docker-machine start <docker machine name>
@FOR /f "tokens=*" %%i IN ('docker-machine env <docker machine name>') DO @%%i
@docker-machine ssh <docker machine name> sudo mount /dev/sdb1 /mnt/sdb1
@docker-compose build
@docker-compose up -d
@REM If the docker machine was completely off, running only 'docker-compose up -d' will
@REM not mount the volumes properly. Stopping and restarting the container results in
@REM the volumes mounting properly.
@docker stop <gitlab container name>
@docker start <gitlab container name>
@pause
注意:gitlab容器名称可以通过运行宁docker-compose up
一次,然后docker ps -a
查看,但通常遵循约定<directory compose file is in>_<name in the compose file, e.g. gitlab here>_1
假设一切顺利并且您根据自己的情况更改了上面 <...> 中的内容,您应该能够 运行 批处理文件并启动 gitlab 并且 运行 以这种方式将所有内容存储在备用驱动器上,vdi 中的持久工作文件(以绕过 VBox POSIX 限制),以及透明存储在共享文件夹中的备份。
希望这可以帮助其他无法访问本地 docker 的可怜人。