- Secrets nötig zur Laufzeit (z.B. in k8s)
- zur Laufzeit im Container verfügbar
- Environment Variablen
- Datei in speziellem mount Pfad
- Secrets nötig beim Build von Images
- NPM Token für private packages
- Auth-Tokens für geschützte Downloads
- ...
FROM node:18-alpine
RUN apk add --no-cache tini
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
COPY geheim.txt .
RUN npm ci --omit=dev
RUN rm geheim.txt
EXPOSE 8080
COPY hello_world.js .
USER node
CMD /sbin/tini -- node hello_world.js
docker build -t hello:latest -f Dockerfile-copy .
docker run -ti --rm -p8080:8080 --name hello hello:latest
docker exec -ti hello /bin/sh
docker inspect hello:latest
docker save hello:latest -o layers.tar
tar xvf layers.tar
for layer in */layer.tar; do \
tar -tf $layer | grep geheim.txt && echo $layer; \
done
tar xvf layer.tar
https://github.com/wagoodman/dive
FROM node:18-alpine
RUN apk add --no-cache tini
WORKDIR /app
ENV NODE_ENV=production
ARG NPM_TOKEN
COPY package*.json ./
RUN npm ci --omit=dev
RUN rm geheim.txt
EXPOSE 8080
COPY hello_world.js .
USER node
CMD /sbin/tini -- node hello_world.js
docker build -t hello:latest \
--build-arg NPM_TOKEN=supageheim \
-f Dockerfile-arg .
docker inspect hello:latest
docker history hello:latest
dive hello:latest
FROM node:18-alpine AS hellobuild
WORKDIR /app
ENV NODE_ENV=production
ARG NPM_TOKEN
COPY package*.json ./
COPY geheim.txt .
RUN npm ci --omit=dev
RUN rm geheim.txt
FROM node:18-alpine
RUN apk add --no-cache tini
WORKDIR /app
ENV NODE_ENV=production
EXPOSE 8080
COPY --from=hellobuild /app/node_modules ./node_modules
COPY hello_world.js .
USER node
CMD /sbin/tini -- node hello_world.js
docker build -t hello:latest \
--build-arg NPM_TOKEN=supageheim \
-f Dockerfile-multistage .
# syntax = docker/dockerfile:1.2
FROM node:18-alpine
RUN apk add --no-cache tini
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
RUN --mount=type=secret,id=geheim,dst=geheim.txt ls -al && npm ci --omit=dev
EXPOSE 8080
COPY hello_world.js .
USER node
CMD /sbin/tini -- node hello_world.js
DOCKER_BUILDKIT=1 docker build -t hello:latest \
--progress=plain --secret id=geheim,src=geheim.txt \
-f Dockerfile-buildkit .
Beispiele: https://github.com/seligerit/slides-docker-secrets/tree/main/docker-examples


