Consider this Dockerfile for a simple Deno app:
FROM denoland/deno:alpine-1.35.3 WORKDIR /app COPY . . RUN deno cache main.ts CMD ["run", "--allow-net", "main.ts"]
The main.ts file contains:
console.log("Hello from Deno in Docker!");What will you see in the container logs after running docker run?
FROM denoland/deno:alpine-1.35.3 WORKDIR /app COPY . . RUN deno cache main.ts CMD ["run", "--allow-net", "main.ts"] // main.ts console.log("Hello from Deno in Docker!");
Think about what console.log does and the permissions given.
The --allow-net flag allows network access but is not required for console.log. The app prints the message and exits normally.
You want to cache dependencies to speed up builds. Which RUN command is correct?
Think about which command downloads and caches dependencies without running the app.
deno cache downloads and caches dependencies without executing the script, which helps speed up subsequent builds.
Given this Dockerfile snippet:
FROM denoland/deno:alpine-1.35.3 WORKDIR /app COPY . . CMD ["run", "main.ts"]
The container fails with a permission error. What is the cause?
Deno requires explicit permission flags to access resources.
By default, Deno denies all permissions. Without flags like --allow-net or --allow-read, the app cannot run if it needs those permissions.
Consider this Dockerfile without caching:
FROM denoland/deno:alpine-1.35.3 WORKDIR /app COPY . . CMD ["run", "--allow-net", "main.ts"]
What is the impact on the build and container startup?
Think about what caching does during build time.
Without caching, dependencies are fetched on every build, slowing down the process. The container still starts fine but build time increases.
Choose the Dockerfile that minimizes image size, caches dependencies, and limits permissions at runtime.
Consider image size, caching, and permission scope.
Option C caches dependencies, compiles the app to a binary (smaller image, faster startup), and runs the binary with minimal permissions. This is best practice.
