Engineering Tools for AI

Programmierung

Docker

Ein Suchleitfaden zu Docker Images, Containern, Dockerfile, Compose, Ports, Volumes, Logs und häufiger Fehlersuche.

33 Treffer

Grundbegriffe

Docker

Docker

docker --version

Bedeutung

A tool for packaging and running applications in isolated containers.

Einsatz

Use it when you want the app to run with the same OS packages, runtime, and dependencies across machines.

Beispiel

docker --version

Anfragebeispiel

Explain whether this project can be run with Docker.

Grundbegriffe

Docker daemon

Docker daemon

Cannot connect to the Docker daemon

Bedeutung

The background service that builds images and runs containers.

Einsatz

If Docker commands cannot connect, Docker Desktop or the Docker service may not be running.

Beispiel

Cannot connect to the Docker daemon

Anfragebeispiel

Check why Docker commands cannot connect to the daemon.

Grundbegriffe

Image

Image

node:20-alpine

Bedeutung

A reusable template used to create containers.

Einsatz

Images define what OS, runtime, libraries, and app files a container starts with.

Beispiel

node:20-alpine

Anfragebeispiel

Tell me which base image this Dockerfile uses.

Grundbegriffe

Container

Container

docker ps

Bedeutung

A running or stopped instance created from an image.

Einsatz

Use containers to run the app, database, cache, or worker in isolated environments.

Beispiel

docker ps

Anfragebeispiel

List running containers and explain what each one does.

Grundbegriffe

Registry

Registry

docker pull postgres:16

Bedeutung

A server where Docker images are stored and downloaded from.

Einsatz

Docker Hub and private registries are used to share base images or deployable app images.

Beispiel

docker pull postgres:16

Anfragebeispiel

Explain where this image will be downloaded from.

Dockerfile

Dockerfile

Dockerfile

Dockerfile

Bedeutung

A file that defines how to build a Docker image.

Einsatz

Use it to install dependencies, copy app files, and define the command that starts the app.

Beispiel

Dockerfile

Anfragebeispiel

Read this Dockerfile and summarize the build steps.

Dockerfile

FROM

FROM

FROM node:20-alpine

Bedeutung

The Dockerfile instruction that chooses the base image.

Einsatz

It decides the starting OS layer and often the runtime version.

Vorsicht

Changing the base image can affect available commands, security updates, and image size.

Beispiel

FROM node:20-alpine

Anfragebeispiel

Explain what this FROM image includes.

Dockerfile

WORKDIR

WORKDIR

WORKDIR /app

Bedeutung

Sets the folder inside the image where following commands run.

Einsatz

Use it so COPY, RUN, and CMD commands operate from a predictable app folder.

Beispiel

WORKDIR /app

Anfragebeispiel

Explain which folder this Dockerfile uses as the app directory.

Dockerfile

COPY

COPY

COPY package.json package-lock.json ./

Bedeutung

Copies files from the build context into the image.

Einsatz

Use it to add dependency files, source code, and static assets to the image.

Beispiel

COPY package.json package-lock.json ./

Anfragebeispiel

Tell me which files this COPY step adds to the image.

Dockerfile

RUN

RUN

RUN npm ci

Bedeutung

Runs a command while building the image.

Einsatz

Use it to install OS packages, install dependencies, or build app files.

Vorsicht

RUN happens at image build time, not when the container starts.

Beispiel

RUN npm ci

Anfragebeispiel

Separate Dockerfile build-time commands from container startup commands.

Dockerfile

CMD

CMD

CMD ["npm", "run", "start"]

Bedeutung

Defines the default command that runs when the container starts.

Einsatz

Use it to start the web server, API server, worker, or script.

Beispiel

CMD ["npm", "run", "start"]

Anfragebeispiel

Tell me what command this container starts with.

Dockerfile

EXPOSE

EXPOSE

EXPOSE 3000

Bedeutung

Documents which port the containerized app is expected to listen on.

Einsatz

Use it as a hint, then publish the port with docker run -p or compose ports.

Vorsicht

EXPOSE alone does not make the app reachable from your browser.

Beispiel

EXPOSE 3000

Anfragebeispiel

Explain whether this exposed port is actually published.

Dockerfile

.dockerignore

.dockerignore

node_modules

Bedeutung

A file that excludes paths from the Docker build context.

Einsatz

Use it to keep local dependencies, build output, secrets, and temporary files out of the image build.

Beispiel

node_modules

Anfragebeispiel

Check whether this .dockerignore excludes unsafe or unnecessary files.

Dockerfile

Build context

Build context

docker build -t my-app .

Bedeutung

The folder sent to Docker during image build.

Einsatz

The final dot in docker build usually means the current folder is the build context.

Vorsicht

A large context slows builds and can accidentally include private files.

Beispiel

docker build -t my-app .

Anfragebeispiel

Explain what files are available to this Docker build.

Docker Compose

Docker Compose

Docker Compose

docker compose up

Bedeutung

A tool for running multiple Docker services from one YAML file.

Einsatz

Use it for app plus database, cache, worker, or local development stacks.

Beispiel

docker compose up

Anfragebeispiel

Explain what services this compose file starts.

Docker Compose

services

services

services: web: db:

Bedeutung

Named app parts defined in a compose file.

Einsatz

A web service might run the app while a db service runs PostgreSQL.

Beispiel

services: web: db:

Anfragebeispiel

List the services in this compose file and what each does.

Docker Compose

docker compose up

docker compose up

docker compose up -d

Bedeutung

Starts the services defined in a compose file.

Einsatz

Use -d when you want services to run in the background.

Beispiel

docker compose up -d

Anfragebeispiel

Start the compose services and show which ones are running.

Docker Compose

docker compose down

docker compose down

docker compose down

Bedeutung

Stops and removes containers created by compose.

Einsatz

Use it when you are done with a local development stack.

Vorsicht

Named volumes usually remain unless you explicitly remove volumes.

Beispiel

docker compose down

Anfragebeispiel

Stop this compose stack without deleting persistent data.

Befehle

docker build

docker build

docker build -t my-app .

Bedeutung

Builds a Docker image from a Dockerfile and context.

Einsatz

Use it after writing a Dockerfile or changing app dependencies.

Beispiel

docker build -t my-app .

Anfragebeispiel

Build this Docker image and summarize any build errors.

Befehle

docker run

docker run

docker run --name my-app -p 3000:3000 my-app

Bedeutung

Creates and starts a container from an image.

Einsatz

Use it when you want to start one container directly without compose.

Beispiel

docker run --name my-app -p 3000:3000 my-app

Anfragebeispiel

Run this image and explain the browser URL.

Befehle

docker ps

docker ps

docker ps

Bedeutung

Lists running containers.

Einsatz

Use docker ps -a when you also want stopped containers.

Beispiel

docker ps

Anfragebeispiel

Show running containers and their published ports.

Befehle

docker stop

docker stop

docker stop my-app

Bedeutung

Stops a running container.

Einsatz

Use it before removing a container or freeing a port.

Beispiel

docker stop my-app

Anfragebeispiel

Stop the container using port 3000.

Befehle

docker logs

docker logs

docker logs my-app

Bedeutung

Prints logs from a container.

Einsatz

Use it when a container exits, crashes, or the app does not respond.

Beispiel

docker logs my-app

Anfragebeispiel

Read this container's logs and find the first error.

Befehle

docker exec

docker exec

docker exec -it my-app sh

Bedeutung

Runs a command inside an already running container.

Einsatz

Use it to inspect files, environment variables, or installed tools inside a container.

Vorsicht

Changes made manually inside a container can disappear when the container is recreated.

Beispiel

docker exec -it my-app sh

Anfragebeispiel

Open a shell in this container and check its environment variables.

Ports und Netzwerk

ports

ports

3000:3000

Bedeutung

Maps a port on your machine to a port inside the container.

Einsatz

Use it so a browser can reach a web app running inside a container.

Vorsicht

The left side is the host port, and the right side is the container port.

Beispiel

3000:3000

Anfragebeispiel

Explain which URL I should open for this ports setting.

Ports und Netzwerk

localhost in Docker

localhost in Docker

host.docker.internal

Bedeutung

localhost can mean the container itself, not your host machine, when code runs inside Docker.

Einsatz

Use service names in compose networks, or host.docker.internal when a container must reach the host machine.

Beispiel

host.docker.internal

Anfragebeispiel

Explain why localhost does not reach the database from this container.

Dateien und Daten

Volume

Volume

db-data:/var/lib/postgresql/data

Bedeutung

Docker-managed storage that can persist data outside a container's lifecycle.

Einsatz

Use volumes for database data or other files that should survive container recreation.

Vorsicht

Removing volumes can delete persistent data.

Beispiel

db-data:/var/lib/postgresql/data

Anfragebeispiel

Tell me which compose volumes store persistent data.

Dateien und Daten

Bind mount

Bind mount

./src:/app/src

Bedeutung

Connects a host folder directly into a container path.

Einsatz

Use it during development so code edits on the host appear inside the container.

Vorsicht

A bind mount can hide files that were copied into the image at the same path.

Beispiel

./src:/app/src

Anfragebeispiel

Explain whether this volume is a named volume or a bind mount.

Dateien und Daten

environment

environment

DATABASE_URL=postgres://db:5432/app

Bedeutung

Configuration values passed into a container.

Einsatz

Use environment variables for database URLs, ports, modes, feature flags, and runtime settings.

Vorsicht

Do not bake secrets into public images or commit real secret values.

Beispiel

DATABASE_URL=postgres://db:5432/app

Anfragebeispiel

Check which environment variables this container needs.

Fehlersuche

port is already allocated

port is already allocated

Bind for 0.0.0.0:3000 failed: port is already allocated

Bedeutung

Docker cannot publish a host port because another process or container is already using it.

Einsatz

Find the process or container using the port, then stop it or choose a different host port.

Beispiel

Bind for 0.0.0.0:3000 failed: port is already allocated

Anfragebeispiel

Find what is using this Docker port and suggest a safe fix.

Fehlersuche

container name is already in use

container name is already in use

Conflict. The container name "/my-app" is already in use

Bedeutung

A container with the same name already exists.

Einsatz

List existing containers, then reuse, remove, or rename the old container.

Beispiel

Conflict. The container name "/my-app" is already in use

Anfragebeispiel

Resolve this container name conflict without deleting data unexpectedly.

Fehlersuche

Build cache

Build cache

docker build --no-cache -t my-app .

Bedeutung

Docker can reuse previous build layers to make builds faster.

Einsatz

If a change seems ignored, inspect the Dockerfile order or rebuild without cache as a diagnostic step.

Vorsicht

--no-cache can make builds slower, so use it intentionally.

Beispiel

docker build --no-cache -t my-app .

Anfragebeispiel

Explain whether Docker build cache could be hiding my change.

Sicherheit

docker system prune

docker system prune

docker system prune

Bedeutung

Removes unused Docker data such as stopped containers, unused networks, and dangling images.

Einsatz

Use it when Docker uses too much disk space and you understand what will be removed.

Vorsicht

With extra flags, prune can delete images or volumes you still care about.

Beispiel

docker system prune

Anfragebeispiel

Before pruning Docker, show what would be removed and what data is safe.