j.J
Deno9mo ago
j.

how to persist data with deno kv when running a docker container?

I’m building a deno project using only the built-in deno kv. I know you can also use the self-hosted backend, but for now that's outside of my scope

I want to containerize the app with docker using a single Dockerfile for simplicity

what I need help with:

- how to persist the local kv data across container runs
- ensuring the non-root deno user can read from and write to the volume where data is stored

currently I have something like:

FROM denoland/deno:alpine-2.2.10
WORKDIR /app
COPY deno.* .
RUN deno install
COPY . .
RUN deno cache server.ts
CMD ["run", "--allow-read", "--allow-write", "server.ts"]

docker build --tag <image-tag> .

docker run -it <image-tag> --mount source=<volume-name>,target=/data


This works, but I have to run the container with the root user (instead of passing the instruction USER deno).

Any guidance or examples would be appreciated!
Was this page helpful?