Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set custom uid and guid ? #236

Closed
kopax opened this issue Oct 26, 2020 · 8 comments · Fixed by #237
Closed

How to set custom uid and guid ? #236

kopax opened this issue Oct 26, 2020 · 8 comments · Fixed by #237
Labels

Comments

@kopax
Copy link

kopax commented Oct 26, 2020

I am reading at https://github.com/docker-library/ghost/blob/3332df18c9d6a11ba0d227b667ba27733a44fafe/3/alpine/Dockerfile and can't find a way to add a custom UID and GID for the container.

Apparently this feature was added before #53

How can I set the custom uid and guid in the official docker ghost image ?

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Oct 26, 2020
@wglambert
Copy link

The PR you linked was closed, not merged. But with the merge of #54 You'd use the --user option

This is implemented in the same way we've supported arbitrary values for docker run --user in many other images.

#19 (comment)

@kopax
Copy link
Author

kopax commented Oct 26, 2020

Hi @wglambert and thank you for your quick reply.

Perhaps you can enlight me, my goal is pretty simple : I want to create an environment of development for ghost with a forked casper theme for docker .

I have followed this recent tutorial : https://www.grottedubarbu.fr/ghost-docker-theme-dev/ (french) to setup a development environment. (I couldn't find a recent resource for ghost 3.0 other than this one)

Within the container, the UID used if I dont set the --user option is 1000, while my own UID is 10000, for editing those files in IntelliJ, I must set the UID within the container to 10000

My docker-compose.yml look like this:

docker-compose
version: '3'
services:
  blog-kop-ax:
    container_name: dev-blog-kop-ax
    image: ghost:3.35.5-alpine
    ports:
      - "2368:2368"
    restart: unless-stopped
    user: "10000:10000"
    volumes:
      - ./content:/var/lib/ghost/content
      - ./themes/blog-kopax:/var/lib/ghost/content/themes/blog-kopax
    environment:
      - NODE_ENV=development
    networks:
      - lan

  node-tools-init:
    image: node:12-buster-slim
    container_name: ghost-tools-init
    restart: on-failure
    user: "10000:10000"
    volumes:
      - ./themes/blog-kopax:/home/node/app/blog-kopax
    working_dir: /home/node/app/blog-kopax
    command: 'yarn install'
    networks:
      - lan


  node-tools:
    image: node:12-buster-slim
    container_name: ghost-tools
    restart: unless-stopped
    user: "10000:10000"
    volumes:
      - ./themes/blog-kopax:/home/node/app/blog-kopax
    working_dir: /home/node/app/blog-kopax
    command: 'yarn dev'
    network_mode: none

networks:
  lan:

The themes/blog-kopax directory is a symlink of a cloned repository of TryGhost/Casper themes

As you expect, with --user 10000, I can see themes/blog-kopax directory using the right folder permissions (10000), but the content folder is always created for root user (while I expected it to be created for 10000).

Also, I expected the content mounted volumes to be created on first run. since my container fail at start, I can see that content/themes/blog-kopax is also created and empty, but also duplicate of theme/blog-kopax (the correct theme directory).

This is the log:

logs
Attaching to dev-blog-kop-ax, ghost-tools, ghost-tools-init
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
ghost-tools-init   | yarn install v1.22.5
ghost-tools-init   | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools-init   | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools-init   | [1/5] Validating package.json...
ghost-tools-init   | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools-init   | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools-init   | [2/5] Resolving packages...
ghost-tools-init   | success Already up-to-date.
ghost-tools-init   | Done in 0.28s.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:18:05] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:18:05] Starting 'default'...
ghost-tools        | [16:18:05] Starting 'css'...
ghost-tools        | [16:18:05] 'css' errored after 588 ms
ghost-tools        | [16:18:05] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:18:05] 'default' errored after 589 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:18:07] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:18:07] Starting 'default'...
ghost-tools        | [16:18:07] Starting 'css'...
ghost-tools        | [16:18:07] 'css' errored after 580 ms
ghost-tools        | [16:18:07] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:18:07] 'default' errored after 581 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:18:09] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:18:09] Starting 'default'...
ghost-tools        | [16:18:09] Starting 'css'...
ghost-tools        | [16:18:09] 'css' errored after 742 ms
ghost-tools        | [16:18:09] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:18:09] 'default' errored after 743 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:18:11] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:18:11] Starting 'default'...
ghost-tools        | [16:18:11] Starting 'css'...
ghost-tools        | [16:18:11] 'css' errored after 570 ms
ghost-tools        | [16:18:11] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:18:11] 'default' errored after 571 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:18:13] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:18:13] Starting 'default'...
ghost-tools        | [16:18:13] Starting 'css'...
ghost-tools        | [16:18:14] 'css' errored after 566 ms
ghost-tools        | [16:18:14] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:18:14] 'default' errored after 568 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:18:17] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:18:17] Starting 'default'...
ghost-tools        | [16:18:17] Starting 'css'...
ghost-tools        | [16:18:17] 'css' errored after 617 ms
ghost-tools        | [16:18:17] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:18:17] 'default' errored after 619 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:18:21] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:18:21] Starting 'default'...
ghost-tools        | [16:18:21] Starting 'css'...
ghost-tools        | [16:18:22] 'css' errored after 567 ms
ghost-tools        | [16:18:22] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:18:22] 'default' errored after 568 ms
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:18:29] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:18:29] Starting 'default'...
ghost-tools        | [16:18:29] Starting 'css'...
ghost-tools        | [16:18:30] 'css' errored after 564 ms
ghost-tools        | [16:18:30] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:18:30] 'default' errored after 566 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:18:44] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:18:44] Starting 'default'...
ghost-tools        | [16:18:44] Starting 'css'...
ghost-tools        | [16:18:45] 'css' errored after 552 ms
ghost-tools        | [16:18:45] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:18:45] 'default' errored after 553 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [16:19:11] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [16:19:11] Starting 'default'...
ghost-tools        | [16:19:11] Starting 'css'...
ghost-tools        | [16:19:12] 'css' errored after 562 ms
ghost-tools        | [16:19:12] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [16:19:12] 'default' errored after 564 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is my working dir :

ls
dka@dka:[~/workspace/git.kopaxgroup.com/kopax/blog (letort)]: ls -altr
total 160
drwxr-xr-x    3 dka  dka   4096 Oct 16 19:12 ..
-rw-r--r--    1 dka  dka     19 Oct 16 19:13 .npmrc
-rw-r--r--    1 dka  dka    456 Oct 16 19:13 .npmignore
-rw-r--r--    1 dka  dka     86 Oct 16 19:13 .ncurc.js
drwxr-xr-x    4 dka  dka   4096 Oct 16 19:13 .gitlab
-rw-r--r--    1 dka  dka     11 Oct 16 19:13 .eslintignore
-rw-r--r--    1 dka  dka    147 Oct 16 19:13 .editorconfig
-rw-r--r--    1 dka  dka     96 Oct 16 19:13 styleguide.config.js
-rw-r--r--    1 dka  dka    388 Oct 16 19:22 sonar-project.properties
-rw-r--r--    1 dka  dka   1436 Oct 16 19:22 .travis.yml
-rw-r--r--    1 dka  dka   1309 Oct 16 19:22 CONTRIBUTING.md
-rw-r--r--    1 dka  dka      0 Oct 16 19:22 CHANGELOG.md
-rw-r--r--    1 dka  dka     65 Oct 16 19:22 LICENSE.md
drwxr-xr-x    3 dka  dka   4096 Oct 16 19:22 internals
-rw-r--r--    1 dka  dka   3191 Oct 16 19:29 CODE_OF_CONDUCT.md
-rw-r--r--    1 dka  dka   1150 Oct 16 19:32 README.md
drwxr-xr-x    3 dka  dka   4096 Oct 18 09:20 docs
drwxr-xr-x    2 dka  dka   4096 Oct 18 09:21 styleguide
-rw-r--r--    1 dka  dka   1608 Oct 18 09:22 .gitlab-ci.yml
-rw-r--r--    1 dka  dka   4268 Oct 18 10:57 package.json
drwxr-xr-x 1417 dka  dka  49152 Oct 18 10:58 node_modules
-rw-r--r--    1 dka  dka   2619 Oct 24 03:40 deploy_prod.json
drwxr-xr-x    8 dka  dka   4096 Oct 26 11:08 .git
-rw-r--r--    1 dka  dka    255 Oct 26 12:09 .gitignore
-rw-r--r--    1 dka  dka      0 Oct 26 12:54 stale_outputs_checked
drwxr-xr-x    2 dka  dka   4096 Oct 26 17:10 themes
-rw-r--r--    1 dka  dka    989 Oct 26 17:13 docker-compose.yml
drwxr-xr-x   11 dka  dka   4096 Oct 26 17:18 .
drwxr-xr-x    3 root root  4096 Oct 26 17:18 content
drwxr-xr-x    2 dka  dka   4096 Oct 26 17:18 .idea

This is my setup:

image

There's obviously something wrong with the permissions despite --user being set.

How would you recommend to setup a development environment for docker and using a forked Casper theme?

@wglambert wglambert added Issue and removed question Usability question, not directly related to an error with the image labels Oct 26, 2020
@wglambert
Copy link

Hmm, looks like running as an arbitrary user no longer works
Using the test example from #54 (comment) :

$ docker run -it --rm --user "$RANDOM:$RANDOM" --name ghost ghost
tar: apps: Cannot mkdir: Permission denied
tar: Exiting with failure status due to previous errors

$ docker run -it --rm --user "$RANDOM:$RANDOM" --name ghost ghost:alpine
tar: can't make dir apps: Permission denied
tar: can't make dir data: Permission denied
tar: can't make dir images: Permission denied
tar: can't make dir logs: Permission denied
tar: can't make dir settings: Permission denied
tar: can't make dir themes: Permission denied
tar: can't create directory 'themes': Permission denied
tar: can't create symlink 'themes/casper' to '/var/lib/ghost/current/content/themes/casper'

$ docker run -it --rm --user "$RANDOM:$RANDOM" --name ghost ghost:2
tar: apps: Cannot mkdir: Permission denied
tar: Exiting with failure status due to previous errors

@tianon
Copy link
Member

tianon commented Oct 26, 2020

Great catch -- not sure how #54 ever worked (although it was probably some bug in my Gentoo system at the time).

Fix is up at #237 👍

@kopax
Copy link
Author

kopax commented Oct 26, 2020

Great, how can I pull this fix from docker hub ?

How about this error tar: can't create symlink 'themes/casper' to '/var/lib/ghost/current/content/themes/casper' ? I named my theme differently, should I rename casper ?

@tianon
Copy link
Member

tianon commented Oct 26, 2020

It's not on Docker Hub yet, but you can build it locally to test with something like docker build --pull https://github.com/docker-library/ghost.git#refs/pull/237/merge:3/alpine (add --tag if you want to tag the image to make it easier to use/test in your docker-compose.yml).

@kopax
Copy link
Author

kopax commented Oct 26, 2020

Thanks for your quick reply, I have tried with --tag but it seems that this options is not available for docker build .

I have just tried with:

$ docker build --pull https://github.com/docker-library/ghost.git#refs/pull/237/merge:3/alpine 
Successfully built 3dfdd3da7248
$ docker tag 3dfdd3da7248 -t custom-ghost
"docker tag" requires exactly 2 arguments.

I'll keep looking for the right CMD.

Anyone, how about my question regarding the casper theme error ? Why does the mounted renamed theme still require a casper to be set?

@kopax
Copy link
Author

kopax commented Oct 27, 2020

Hi all, I have tried with the latest image and I still have some permissions issues :

docker-compose logs
Attaching to dev-blog-kop-ax, ghost-tools, ghost-tools-init
ghost-tools-init   | yarn install v1.22.5
ghost-tools-init   | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools-init   | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools-init   | [1/5] Validating package.json...
ghost-tools-init   | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools-init   | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools-init   | [2/5] Resolving packages...
ghost-tools-init   | success Already up-to-date.
ghost-tools-init   | Done in 0.33s.
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
dev-blog-kop-ax    | tar: can't make dir apps: Permission denied
dev-blog-kop-ax    | tar: can't make dir data: Permission denied
dev-blog-kop-ax    | tar: can't make dir images: Permission denied
dev-blog-kop-ax    | tar: can't make dir logs: Permission denied
dev-blog-kop-ax    | tar: can't make dir settings: Permission denied
dev-blog-kop-ax    | tar: can't create symlink 'casper' to '/var/lib/ghost/current/content/themes/casper'
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [14:23:36] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [14:23:36] Starting 'default'...
ghost-tools        | [14:23:36] Starting 'css'...
ghost-tools        | [14:23:36] 'css' errored after 658 ms
ghost-tools        | [14:23:36] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [14:23:36] 'default' errored after 660 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [14:23:38] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [14:23:38] Starting 'default'...
ghost-tools        | [14:23:38] Starting 'css'...
ghost-tools        | [14:23:39] 'css' errored after 1.08 s
ghost-tools        | [14:23:39] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [14:23:39] 'default' errored after 1.08 s
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [14:23:41] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [14:23:41] Starting 'default'...
ghost-tools        | [14:23:41] Starting 'css'...
ghost-tools        | [14:23:42] 'css' errored after 876 ms
ghost-tools        | [14:23:42] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [14:23:42] 'default' errored after 879 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [14:23:44] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [14:23:44] Starting 'default'...
ghost-tools        | [14:23:44] Starting 'css'...
ghost-tools        | [14:23:45] 'css' errored after 1.04 s
ghost-tools        | [14:23:45] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [14:23:45] 'default' errored after 1.05 s
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ghost-tools        | yarn run v1.22.5
ghost-tools        | warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
ghost-tools        | warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
ghost-tools        | warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-10000".
ghost-tools        | warning [email protected]: The engine "ghost" appears to be invalid.
ghost-tools        | warning [email protected]: The engine "ghost-api" appears to be invalid.
ghost-tools        | $ gulp
ghost-tools        | warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
ghost-tools        | [14:23:47] Using gulpfile /home/node/app/blog-kopax/gulpfile.js
ghost-tools        | [14:23:47] Starting 'default'...
ghost-tools        | [14:23:47] Starting 'css'...
ghost-tools        | [14:23:48] 'css' errored after 956 ms
ghost-tools        | [14:23:48] Error: EACCES: permission denied, open '/home/node/app/blog-kopax/assets/built/global.css'
ghost-tools        | [14:23:48] 'default' errored after 958 ms
ghost-tools        | error Command failed with exit code 1.
ghost-tools        | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ls -altr
dka@dka:[~/workspace/git.kopaxgroup.com/kopax/blog (letort)]: ll
total 160
drwxr-xr-x    3 dka  dka   4096 Oct 16 19:12 ..
-rw-r--r--    1 dka  dka     19 Oct 16 19:13 .npmrc
-rw-r--r--    1 dka  dka    456 Oct 16 19:13 .npmignore
-rw-r--r--    1 dka  dka     86 Oct 16 19:13 .ncurc.js
drwxr-xr-x    4 dka  dka   4096 Oct 16 19:13 .gitlab
-rw-r--r--    1 dka  dka     11 Oct 16 19:13 .eslintignore
-rw-r--r--    1 dka  dka    147 Oct 16 19:13 .editorconfig
-rw-r--r--    1 dka  dka     96 Oct 16 19:13 styleguide.config.js
-rw-r--r--    1 dka  dka    388 Oct 16 19:22 sonar-project.properties
-rw-r--r--    1 dka  dka   1436 Oct 16 19:22 .travis.yml
-rw-r--r--    1 dka  dka   1309 Oct 16 19:22 CONTRIBUTING.md
-rw-r--r--    1 dka  dka      0 Oct 16 19:22 CHANGELOG.md
-rw-r--r--    1 dka  dka     65 Oct 16 19:22 LICENSE.md
drwxr-xr-x    3 dka  dka   4096 Oct 16 19:22 internals
-rw-r--r--    1 dka  dka   3191 Oct 16 19:29 CODE_OF_CONDUCT.md
-rw-r--r--    1 dka  dka   1150 Oct 16 19:32 README.md
drwxr-xr-x    3 dka  dka   4096 Oct 18 09:20 docs
drwxr-xr-x    2 dka  dka   4096 Oct 18 09:21 styleguide
-rw-r--r--    1 dka  dka   1608 Oct 18 09:22 .gitlab-ci.yml
-rw-r--r--    1 dka  dka   4268 Oct 18 10:57 package.json
drwxr-xr-x 1417 dka  dka  49152 Oct 18 10:58 node_modules
-rw-r--r--    1 dka  dka   2619 Oct 24 03:40 deploy_prod.json
drwxr-xr-x    8 dka  dka   4096 Oct 26 11:08 .git
-rw-r--r--    1 dka  dka    255 Oct 26 12:09 .gitignore
-rw-r--r--    1 dka  dka      0 Oct 26 12:54 stale_outputs_checked
drwxr-xr-x    2 dka  dka   4096 Oct 26 17:10 themes
-rw-r--r--    1 dka  dka    989 Oct 27 15:20 docker-compose.yml
drwxr-xr-x    2 dka  dka   4096 Oct 27 15:20 .idea
drwxr-xr-x   11 dka  dka   4096 Oct 27 15:23 .
drwxr-xr-x    3 root root  4096 Oct 27 15:23 content

content directory is still owned by root instead of user with id 10000

EDIT

I was able to have a working development environment only after doing a sudo chown -R 10000:10000 themes and sudo chown -R 10000:10000 content

I want to add my theme in a docker image, I can't find any information, how can I add my default theme using Dockerfile ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants