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

Permission denied! #107

Closed
ghost opened this issue Feb 8, 2021 · 2 comments
Closed

Permission denied! #107

ghost opened this issue Feb 8, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 8, 2021

Hi!

  1. I write simple test:
import { Application } from 'https://deno.land/x/abc@v1.2.4/mod.ts'

const app = new Application()

const test = 'Test string'
const encoder = new TextEncoder()
const data = encoder.encode(test)

app.get('/', async (c) => {
    await Deno.writeFile('test.txt', data)
    return test
})

app.start({ 
    port: 8080 
})

it allows you to understand how the file is being created and written.

  1. Dockerfile
FROM hayd/alpine-deno:1.7.2
EXPOSE 8080
WORKDIR /app
USER deno
ADD . .
RUN deno cache app.js
CMD ["run", "--allow-net", "--allow-read", "--allow-write", "app.js"]
  1. Run command in your example: docker build -t app . && docker run -it --init -p 8080:8080 app

Without writing files, everything works fine, but if create and write files, I see an error:

Screenshot_1

I test this example with Alpine Linux & CentOS
I'm doing this for the first time, maybe it's a simple task, but please tell me how to fix it?

@hayd
Copy link
Contributor

hayd commented Feb 8, 2021

By default:

USER deno

won't have access to write files. This is by design.

What you should do is either remove the USER deno or set the permissions of /app (or another directory) to be writable by the deno user e.g. something like chown -R deno /app.

@ghost
Copy link
Author

ghost commented Feb 8, 2021

thank you very much!
You've helped me a lot!

@ghost ghost closed this as completed Feb 8, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant