This flag further enhances security, however without further changes this flag will generate warnings because the `deno` executable needs to write twice: (1) to generate a dependency analysis cache, and (2) to generate a code cache.
(1) is resolved by adding a command to run `deno` once in the `Dockerfile`, to instantiate the analysis cache during image build.
(2) is resolved by adding `--no-code-cache` to the `deno run` command, which will avoid generating the code cache.
FROM denoland/deno:alpine-2.3.5
USER deno
+# Instantiate analysis cache to avoid console warnings later when running this image with the --read-only flag
+RUN deno
COPY main.ts .
-CMD ["run", "main.ts"]
\ No newline at end of file
+CMD ["run", "--no-code-cache", "main.ts"]
\ No newline at end of file
docker build -t spt .
```
-2. Create a new container without network access and run the CLI:
+2. Create a new container with restrictive permissions and run the CLI:
```
-docker run -it --rm --network none spt
+docker run -it --rm --read-only --network none spt
```