3
votes

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.

1
In the volumes declaration . refers to your host's current directory. What are the permissions on that directory? Who is the owner? It would be better to replace . with ./jekyll and put in the new directory whatever files you need. Then you can try and give more write rights to this directory.Mihai
@Mihai The permissions for the directory I am running the command in are drwxr-xr-x 12 addison addison 4.0K Aug 14 15:50.Addison
try to add this volume as well: - ./_site:/srv/jekyll/_site This way the folder will be created by docker-compose with the correct permissions.Mihai
@Mihai I was able to get the site built after executing the command chmod ugo+rwx site and then using docker-compose up. When I add the line you suggested, I get another error jekyll 3.8.5 | Error: Permission denied @ rb_sysopen - /srv/jekyll/_site/blog.html. I am not exactly satisfied with my solution, as I have other peers that do not have to modify their directory permissions, or change the docker-compose.yml file.Addison
Since you managed to run the project before I guess the folder was already created when you tried my solution. Or are you sure it was not there?Mihai

1 Answers

3
votes

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