J.
J.
DDeno
Created by J. on 4/18/2025 in #help
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"]
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 build --tag <image-tag> .
docker run -it <image-tag> --mount source=<volume-name>,target=/data
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!
1 replies