まじか! docker の volume にパスの長さが影響するなんて (gitlab)


結論

  • gitlab を docker で立ち上げる時、 --volume のパスの長さが、長過ぎる時は気をつけろ。

正常起動

  • 正常起動とエラーとの違いは、 volume のパス。
    • 正常起動: ${HOME}/Downloads
    • エラー: ${PWD}
  • HOME と PWD を展開した時の長さが全然違う。(今回の場合の桁数)
    • 正常起動(HOME): 14 バイト
    • エラー(PWD): 83 バイト
docker run --detach \
  --hostname localhost \
  --publish 10080:80 \
  --publish 10022:22 \
  --name gitlab \
  --restart always \
  --volume ${HOME}/Downloads/gitlab/config:/etc/gitlab \
  --volume ${HOME}/Downloads/gitlab/logs:/var/log/gitlab \
  --volume ${HOME}/Downloads/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest

エラー

docker run --detach \
  --hostname localhost \
  --publish 10080:80 \
  --publish 10022:22 \
  --name gitlab \
  --restart always \
  --volume ${PWD}/gitlab/config:/etc/gitlab \
  --volume ${PWD}/gitlab/logs:/var/log/gitlab \
  --volume ${PWD}/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest
  • エラー内容
Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
There was an error running gitlab-ctl reconfigure:

bash[migrate gitlab-rails database] (gitlab::database_migrations line 51) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash"  "/tmp/chef-script20190521-24-51lpum" ----
STDOUT: rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:55:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:db:configure
(See full trace by running task with --trace)
STDERR: 
---- End output of "bash"  "/tmp/chef-script20190521-24-51lpum" ----
Ran "bash"  "/tmp/chef-script20190521-24-51lpum" returned 1