Engineering Tools for AI

Programming

Docker

A searchable guide to Docker images, containers, Dockerfile instructions, Docker Compose, ports, volumes, logs, and common troubleshooting steps.

33 matching items

Core concepts

Docker

Docker

docker --version

Meaning

A tool for packaging and running applications in isolated containers.

When to use it

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

Example

docker --version

Request example

Explain whether this project can be run with Docker.

Core concepts

Docker daemon

Docker daemon

Cannot connect to the Docker daemon

Meaning

The background service that builds images and runs containers.

When to use it

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

Example

Cannot connect to the Docker daemon

Request example

Check why Docker commands cannot connect to the daemon.

Core concepts

Image

Image

node:20-alpine

Meaning

A reusable template used to create containers.

When to use it

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

Example

node:20-alpine

Request example

Tell me which base image this Dockerfile uses.

Core concepts

Container

Container

docker ps

Meaning

A running or stopped instance created from an image.

When to use it

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

Example

docker ps

Request example

List running containers and explain what each one does.

Core concepts

Registry

Registry

docker pull postgres:16

Meaning

A server where Docker images are stored and downloaded from.

When to use it

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

Example

docker pull postgres:16

Request example

Explain where this image will be downloaded from.

Dockerfile

Dockerfile

Dockerfile

Dockerfile

Meaning

A file that defines how to build a Docker image.

When to use it

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

Example

Dockerfile

Request example

Read this Dockerfile and summarize the build steps.

Dockerfile

FROM

FROM

FROM node:20-alpine

Meaning

The Dockerfile instruction that chooses the base image.

When to use it

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

Caution

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

Example

FROM node:20-alpine

Request example

Explain what this FROM image includes.

Dockerfile

WORKDIR

WORKDIR

WORKDIR /app

Meaning

Sets the folder inside the image where following commands run.

When to use it

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

Example

WORKDIR /app

Request example

Explain which folder this Dockerfile uses as the app directory.

Dockerfile

COPY

COPY

COPY package.json package-lock.json ./

Meaning

Copies files from the build context into the image.

When to use it

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

Example

COPY package.json package-lock.json ./

Request example

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

Dockerfile

RUN

RUN

RUN npm ci

Meaning

Runs a command while building the image.

When to use it

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

Caution

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

Example

RUN npm ci

Request example

Separate Dockerfile build-time commands from container startup commands.

Dockerfile

CMD

CMD

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

Meaning

Defines the default command that runs when the container starts.

When to use it

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

Example

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

Request example

Tell me what command this container starts with.

Dockerfile

EXPOSE

EXPOSE

EXPOSE 3000

Meaning

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

When to use it

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

Caution

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

Example

EXPOSE 3000

Request example

Explain whether this exposed port is actually published.

Dockerfile

.dockerignore

.dockerignore

node_modules

Meaning

A file that excludes paths from the Docker build context.

When to use it

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

Example

node_modules

Request example

Check whether this .dockerignore excludes unsafe or unnecessary files.

Dockerfile

Build context

Build context

docker build -t my-app .

Meaning

The folder sent to Docker during image build.

When to use it

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

Caution

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

Example

docker build -t my-app .

Request example

Explain what files are available to this Docker build.

Docker Compose

Docker Compose

Docker Compose

docker compose up

Meaning

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

When to use it

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

Example

docker compose up

Request example

Explain what services this compose file starts.

Docker Compose

services

services

services: web: db:

Meaning

Named app parts defined in a compose file.

When to use it

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

Example

services: web: db:

Request example

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

Docker Compose

docker compose up

docker compose up

docker compose up -d

Meaning

Starts the services defined in a compose file.

When to use it

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

Example

docker compose up -d

Request example

Start the compose services and show which ones are running.

Docker Compose

docker compose down

docker compose down

docker compose down

Meaning

Stops and removes containers created by compose.

When to use it

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

Caution

Named volumes usually remain unless you explicitly remove volumes.

Example

docker compose down

Request example

Stop this compose stack without deleting persistent data.

Commands

docker build

docker build

docker build -t my-app .

Meaning

Builds a Docker image from a Dockerfile and context.

When to use it

Use it after writing a Dockerfile or changing app dependencies.

Example

docker build -t my-app .

Request example

Build this Docker image and summarize any build errors.

Commands

docker run

docker run

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

Meaning

Creates and starts a container from an image.

When to use it

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

Example

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

Request example

Run this image and explain the browser URL.

Commands

docker ps

docker ps

docker ps

Meaning

Lists running containers.

When to use it

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

Example

docker ps

Request example

Show running containers and their published ports.

Commands

docker stop

docker stop

docker stop my-app

Meaning

Stops a running container.

When to use it

Use it before removing a container or freeing a port.

Example

docker stop my-app

Request example

Stop the container using port 3000.

Commands

docker logs

docker logs

docker logs my-app

Meaning

Prints logs from a container.

When to use it

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

Example

docker logs my-app

Request example

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

Commands

docker exec

docker exec

docker exec -it my-app sh

Meaning

Runs a command inside an already running container.

When to use it

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

Caution

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

Example

docker exec -it my-app sh

Request example

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

Ports and network

ports

ports

3000:3000

Meaning

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

When to use it

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

Caution

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

Example

3000:3000

Request example

Explain which URL I should open for this ports setting.

Ports and network

localhost in Docker

localhost in Docker

host.docker.internal

Meaning

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

When to use it

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

Example

host.docker.internal

Request example

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

Files and data

Volume

Volume

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

Meaning

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

When to use it

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

Caution

Removing volumes can delete persistent data.

Example

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

Request example

Tell me which compose volumes store persistent data.

Files and data

Bind mount

Bind mount

./src:/app/src

Meaning

Connects a host folder directly into a container path.

When to use it

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

Caution

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

Example

./src:/app/src

Request example

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

Files and data

environment

environment

DATABASE_URL=postgres://db:5432/app

Meaning

Configuration values passed into a container.

When to use it

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

Caution

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

Example

DATABASE_URL=postgres://db:5432/app

Request example

Check which environment variables this container needs.

Troubleshooting

port is already allocated

port is already allocated

Bind for 0.0.0.0:3000 failed: port is already allocated

Meaning

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

When to use it

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

Example

Bind for 0.0.0.0:3000 failed: port is already allocated

Request example

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

Troubleshooting

container name is already in use

container name is already in use

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

Meaning

A container with the same name already exists.

When to use it

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

Example

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

Request example

Resolve this container name conflict without deleting data unexpectedly.

Troubleshooting

Build cache

Build cache

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

Meaning

Docker can reuse previous build layers to make builds faster.

When to use it

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

Caution

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

Example

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

Request example

Explain whether Docker build cache could be hiding my change.

Safety

docker system prune

docker system prune

docker system prune

Meaning

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

When to use it

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

Caution

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

Example

docker system prune

Request example

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