Docker: Unterschied zwischen den Versionen

Aus Zovis Wikili
Wechseln zu: Navigation, Suche
(get in to a Docker)
(im VSC ein file per CMD öffnen)
 
(5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 3: Zeile 3:
 
  docker exec -it [mycontainer or ID] sh
 
  docker exec -it [mycontainer or ID] sh
  
= Dockerfile =
+
= Dockerfile Basic Syntax =
 
<pre>
 
<pre>
 
```Dockerfile
 
```Dockerfile
Zeile 21: Zeile 21:
 
CMD ["node", "src/index.js"]
 
CMD ["node", "src/index.js"]
 
</pre>
 
</pre>
 +
 +
= [Additional Dockerfile instructions https://docs.docker.com/reference/dockerfile/] =
 +
<pre>
 +
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)
 +
</pre>
 +
 +
 +
= Multistaging =
 +
 +
diff -y 1030-images/exercise/hello-go-multistage.Dockerfile 1030-images/solution/hello-go-multistage.Dockerfile || true
 +
 +
= im VSC ein file per CMD öffnen =
 +
$ code-server 1030-images/solution/hello-go-secure.Dockerfile
 +
 +
 +
= laps =
 +
= isovalent laps =
 +
https://isovalent.com/labs/cilium-gateway-api-advanced/

Aktuelle Version vom 27. Mai 2026, 11:00 Uhr

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)


Multistaging

diff -y 1030-images/exercise/hello-go-multistage.Dockerfile 1030-images/solution/hello-go-multistage.Dockerfile || true

im VSC ein file per CMD öffnen

$ code-server 1030-images/solution/hello-go-secure.Dockerfile


laps

isovalent laps

https://isovalent.com/labs/cilium-gateway-api-advanced/