envygeeks / jekyll-docker

⛴ Docker images, and CI builders for Jekyll.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Permission denied @ dir_s_mkdir

sergio-ns opened this issue · comments

Hello,
I'm trying to create a new site and I get this error message (full trace below):
jekyll 4.2.0 | Error: Permission denied @ dir_s_mkdir - /srv/jekyll/mysite

This is my docker compose yml:

version: '3'

services:
   new:
      image: jekyll/jekyll:4.0
      container_name: jekyll_new
      volumes:
         - /share/DockerVolumes/jekyll/mysite:/srv/jekyll
      command: 'jekyll new mysite'

      environment:
         - JEKYLL_UID=0
         - JEKYLL_GID=0

The command I'm running (as root) is:
docker-compose up new

Full trace:

[~/dck/dc/jekyll] # docker-compose up new
Recreating jekyll_new ... done
Attaching to jekyll_new
new_1    | ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux-musl]
new_1    | jekyll 4.2.0 | Error:  Permission denied @ dir_s_mkdir - /srv/jekyll/mysite
new_1    | /usr/local/lib/ruby/2.7.0/fileutils.rb:250:in `mkdir': Permission denied @ dir_s_mkdir - /srv/jekyll/mysite (Errno::EACCES)
new_1    |      from /usr/local/lib/ruby/2.7.0/fileutils.rb:250:in `fu_mkdir'
new_1    |      from /usr/local/lib/ruby/2.7.0/fileutils.rb:228:in `block (2 levels) in mkdir_p'
new_1    |      from /usr/local/lib/ruby/2.7.0/fileutils.rb:226:in `reverse_each'
new_1    |      from /usr/local/lib/ruby/2.7.0/fileutils.rb:226:in `block in mkdir_p'
new_1    |      from /usr/local/lib/ruby/2.7.0/fileutils.rb:211:in `each'
new_1    |      from /usr/local/lib/ruby/2.7.0/fileutils.rb:211:in `mkdir_p'
new_1    |      from /usr/gem/gems/jekyll-4.2.0/lib/jekyll/commands/new.rb:28:in `process'
new_1    |      from /usr/gem/gems/jekyll-4.2.0/lib/jekyll/commands/new.rb:19:in `block (2 levels) in init_with_program'
new_1    |      from /usr/gem/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
new_1    |      from /usr/gem/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
new_1    |      from /usr/gem/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
new_1    |      from /usr/gem/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
new_1    |      from /usr/gem/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
new_1    |      from /usr/gem/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
new_1    |      from /usr/gem/bin/jekyll:23:in `load'
new_1    |      from /usr/gem/bin/jekyll:23:in `<main>'
jekyll_new exited with code 1

Thanks
S.

Fixed by creating a new user (jekyll), changing environment variables to:

      environment:
         - JEKYLL_UID=1000
         - JEKYLL_GID=1000

and creating upfront the site directory and granting privileges to user jekyll.
The above should be mentioned in the documentation, for the benefit of those who are not familiar with ruby.
But now I'm stuck at Issue #272

Thanks