docker run gitlab-ce with '--volume' option set get error: initdb: could not create directory "...": Permission denied
Created by: mdluo
I have docker-machine installed on OS X 10.11 and use
docker run --detach \
--hostname gitlab.example.com \
--publish 80:80 --publish 2222:22 \
--name gitlab \
--restart always \
--volume /Users/user/Sites/gitlab/config:/etc/gitlab \
--volume /Users/user/Sites/gitlab/logs:/var/log/gitlab \
--volume /Users/user/Sites/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
to run the latest gitlab-ce image.
I have chmod -R 777 /Users/user/Sites/gitlab
but still got error like this:
[2015-10-04T10:07:51+00:00] INFO: Retrying execution of execute[/opt/gitlab/bin/gitlab-ctl start redis], 19 attempt(s) left
[2015-10-04T10:07:53+00:00] INFO: Retrying execution of execute[/opt/gitlab/bin/gitlab-ctl start redis], 18 attempt(s) left
[2015-10-04T10:08:26+00:00] INFO: Retrying execution of execute[/opt/gitlab/bin/gitlab-ctl start redis], 17 attempt(s) left
[2015-10-04T10:08:59+00:00] INFO: Retrying execution of execute[/opt/gitlab/bin/gitlab-ctl start redis], 16 attempt(s) left
[2015-10-04T10:09:31+00:00] INFO: Retrying execution of execute[/opt/gitlab/bin/gitlab-ctl start redis], 15 attempt(s) left
[2015-10-04T10:09:56+00:00] INFO: execute[/opt/gitlab/bin/gitlab-ctl start redis] ran successfully
[2015-10-04T10:09:56+00:00] INFO: directory[/var/opt/gitlab/postgresql] owner changed to 996
[2015-10-04T10:09:56+00:00] INFO: directory[/var/opt/gitlab/postgresql] mode changed to 755
[2015-10-04T10:09:56+00:00] INFO: directory[/var/opt/gitlab/postgresql/data] owner changed to 996
[2015-10-04T10:09:56+00:00] INFO: directory[/var/opt/gitlab/postgresql/data] mode changed to 700
[2015-10-04T10:09:56+00:00] INFO: directory[/var/log/gitlab/postgresql] owner changed to 996
[2015-10-04T10:09:56+00:00] INFO: directory[/var/log/gitlab/postgresql] mode changed to 700
[2015-10-04T10:09:56+00:00] INFO: file[/var/opt/gitlab/postgresql/.profile] owner changed to 996
[2015-10-04T10:09:56+00:00] INFO: execute[sysctl] ran successfully
[2015-10-04T10:09:56+00:00] INFO: ruby_block[maintain sysctl config] called
[2015-10-04T10:09:56+00:00] INFO: execute[sysctl] ran successfully
[2015-10-04T10:09:56+00:00] INFO: ruby_block[maintain sysctl config] called
================================================================================
Error executing action `run` on resource 'execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.
The database cluster will be initialized with locale "C.UTF-8".
The default text search configuration will be set to "english".
fixing permissions on existing directory /var/opt/gitlab/postgresql/data ... ok
creating subdirectories ...
STDERR: initdb: could not create directory "/var/opt/gitlab/postgresql/data/pg_xlog/archive_status": Permission denied
initdb: removing contents of data directory "/var/opt/gitlab/postgresql/data"
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/postgresql.rb
76: execute "/opt/gitlab/embedded/bin/initdb -D #{postgresql_data_dir} -E UTF8" do
77: user postgresql_user
78: not_if { File.exists?(File.join(postgresql_data_dir, "PG_VERSION")) }
79: end
80:
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/postgresql.rb:76:in `from_file'
execute("/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8") do
action [:run]
retries 0
retry_delay 2
default_guard_interpreter :execute
command "/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8"
backup 5
returns 0
user "gitlab-psql"
declared_type :execute
cookbook_name "gitlab"
recipe_name "postgresql"
not_if { #code block }
end
[2015-10-04T10:09:56+00:00] INFO: Running queued delayed notifications before re-raising exception
[2015-10-04T10:09:56+00:00] INFO: template[/var/opt/gitlab/gitlab-rails/etc/gitlab.yml] sending run action to execute[clear the gitlab-rails cache] (delayed)
================================================================================
Error executing action `run` on resource 'execute[clear the gitlab-rails cache]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/bin/gitlab-rake cache:clear ----
STDOUT:
STDERR: Rails Error: Unable to access log file. Please ensure that /opt/gitlab/embedded/service/gitlab-rails/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
rake aborted!
Errno::ENOENT: No such file or directory - connect(2) for /var/opt/gitlab/redis/redis.socket
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/connection/ruby.rb:180:in `connect_nonblock'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/connection/ruby.rb:180:in `connect'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/connection/ruby.rb:209:in `connect'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:322:in `establish_connection'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:94:in `block in connect'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:279:in `with_reconnect'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:93:in `connect'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:350:in `ensure_connected'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:207:in `block in process'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:292:in `logging'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:206:in `process'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:112:in `call'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:441:in `block in keys'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:37:in `block in synchronize'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:37:in `synchronize'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:440:in `keys'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-store-1.1.6/lib/redis/store/namespace.rb:37:in `block in keys'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-store-1.1.6/lib/redis/store/namespace.rb:74:in `namespace'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/redis-store-1.1.6/lib/redis/store/namespace.rb:37:in `keys'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/cache.rake:7:in `block (2 levels) in <top (required)>'
Tasks: TOP => cache:clear
(See full trace by running task with --trace)
---- End output of /opt/gitlab/bin/gitlab-rake cache:clear ----
Ran /opt/gitlab/bin/gitlab-rake cache:clear returned 1
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/gitlab-rails.rb
284: execute "clear the gitlab-rails cache" do
285: command "/opt/gitlab/bin/gitlab-rake cache:clear"
286: action :nothing
287: end
288:
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/gitlab-rails.rb:284:in `from_file'
execute("clear the gitlab-rails cache") do
action [:nothing]
retries 0
retry_delay 2
default_guard_interpreter :execute
command "/opt/gitlab/bin/gitlab-rake cache:clear"
backup 5
returns 0
declared_type :execute
cookbook_name "gitlab"
recipe_name "gitlab-rails"
end
[2015-10-04T10:10:06+00:00] INFO: template[/var/log/gitlab/redis/config] sending create action to ruby_block[reload redis svlogd configuration] (delayed)
[2015-10-04T10:10:06+00:00] INFO: ruby_block[reload redis svlogd configuration] called
[2015-10-04T10:10:06+00:00] ERROR: Running exception handlers
[2015-10-04T10:10:06+00:00] ERROR: Exception handlers complete
[2015-10-04T10:10:06+00:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out
[2015-10-04T10:10:06+00:00] ERROR: Chef::Exceptions::MultipleFailures
[2015-10-04T10:10:07+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
If I remove those --volume
lines, it goes alright with 0 error.
But I really need to mount the data up :(