Docker
Version vom 26. Mai 2026, 12:31 Uhr von Zovi (Diskussion | Beiträge) (→[Additional Dockerfile instructions][https://docs.docker.com/reference/dockerfile/])
get in to a Docker
docker exec -it [mycontainer or ID] sh
Dockerfile Basic Syntax
```Dockerfile # Base image to build layer on top FROM node:18-alpine # Working directory for build and runtime WORKDIR /app # Copy from "build context" into container image COPY . . # Run command during build time RUN npm install # Instructions what to run when container starts CMD ["node", "src/index.js"]
[Additional Dockerfile instructions https://docs.docker.com/reference/dockerfile/]
ENV - Variables available to RUN commands and on container execution.
ARG - Arguments you can pass to `docker build` to customize an image.
RUN \
--mount - Mount a volume during build.
--network - To deactivate the network for this step or to use the host network.
--security - Similar to `docker run --priviliged` for build time.
USER - User and group ID used for the following RUN, CMD and/or ENTRYPOINT.
SHELL - Override default shell for RUN, CMD and ENTRYPOINT (e.g. powershell instead of cmd in Windows Containers).
EXPOSE - "Documentation" about which ports should be exposed (no actual effect).
VOLUME - Creates volumes on `docker run` ("ignored" by Kubernetes).
ONBUILD - Sneak in Dockerfile instructions if image is used as base image (scary magical feature).
STOPSIGNAL - Signal to stop container ie. SIGKILL, SIGTERM...
HEALTHCHECK - Docker specific feature for health checks (ignored by Kubernetes).
LABEL - Metadata key value pairs: org.opencontainers.image.authors="hans@letsboot.ch"
MAINTAINER - Sets the Author field of the generated images (deprecated)