Addison
Addison

Reputation: 31

Unable to build cloned Jekyll site - jekyll 3.8.5 | Error: Permission denied @ dir_s_mkdir - /srv/jekyll/_site

I am unable to build the jekyll site I cloned with git due to a permission error. I am using Ubuntu 18.04. I've looked at most SO posts regarding this error, but none of the solutions have worked for me.

The command to build the site is docker-compose up. Running this command with or without sudo does not change the error. I am in the docker group. I am able to build the site using bundle exec jekyll serve. This command successfully creates the _site folder.

I tried adding the _site manually, but this results in a different error.

$ docker-compose up         
Starting site ... done
Attaching to site
site | Configuration file: /srv/jekyll/_config.yml
site |             Source: /srv/jekyll
site |        Destination: /srv/jekyll/_site
site |  Incremental build: disabled. Enable with --incremental
site |       Generating... 
site |        Jekyll Feed: Generating feed for posts
site | jekyll 3.8.5 | Error:  Permission denied @ dir_s_mkdir - /srv/jekyll/_site
site exited with code 1

docker-compose.yml

version: '3'
services:
  doc:
    image: jekyll/jekyll:3.8
    volumes:
      - .:/srv/jekyll
    container_name: site
    ports:
      - "4000:4000"
    stdin_open: true
    tty: true
    command: bash -c "bundle install && bundle exec jekyll serve --host 0.0.0.0"

I am expecting to get no errors and have the _site directory successfully created.

Upvotes: 3

Views: 2240

Answers (1)

Rodrigo A. Costa
Rodrigo A. Costa

Reputation: 71

I have the same issue, what I understand from the problem, is that the image jekyll/jekyll:3.8 create a group and user called jekyll under the UID 1000 which is the first user from Ubuntu(in my case).

When you try to run your compose file with another user where is different from the user UID 1000 the volume you mount has the owner from this current user, which is not the same UID of jekyll, then when your service try to run something he has no permission.

To solve that I found in this repository this environment variables: JEKYLL_UID = 1000 JEKYLL_GID = 1000

adding in the compose file the env variables and changing the value 1000 to the UID from the current user.

    environment:
      JEKYLL_UID: 1001
      JEKYLL_GID: 1001

This works fine to me.

To print your current UID :

$ echo $UID
1001

Upvotes: 7

Related Questions