codegurukool.com · Free coding tutorials & online compiler

Home › Docker Tutorial › All commands

All commands

Every command of this course: name, detailed description, syntax and example code.

Every command used in this course, with its name, a detailed description, the syntax and an example.

docker

Definition: The Docker daemon ( dockerd ) does the work and the docker command is the client that talks to it.

Syntax:

docker

Example:

docker run hello-world

↗ Images, containers and registries

FROM

Definition: FROM picks the base image, WORKDIR sets the working folder, COPY adds files, RUN runs a command while building, EXPOSE documents a port and CMD is what runs when the container starts.

Syntax:

FROM

Example:

FROM node:22-alpine

↗ Dockerfile

WORKDIR

Definition: FROM picks the base image, WORKDIR sets the working folder, COPY adds files, RUN runs a command while building, EXPOSE documents a port and CMD is what runs when the container starts.

Syntax:

WORKDIR

Example:

WORKDIR /app

↗ Dockerfile

COPY

Definition: FROM picks the base image, WORKDIR sets the working folder, COPY adds files, RUN runs a command while building, EXPOSE documents a port and CMD is what runs when the container starts.

Syntax:

COPY

Example:

COPY package.json ./
COPY . .

↗ Dockerfile

RUN

Definition: FROM picks the base image, WORKDIR sets the working folder, COPY adds files, RUN runs a command while building, EXPOSE documents a port and CMD is what runs when the container starts.

Syntax:

RUN

Example:

RUN npm install --omit=dev

↗ Dockerfile

EXPOSE

Definition: FROM picks the base image, WORKDIR sets the working folder, COPY adds files, RUN runs a command while building, EXPOSE documents a port and CMD is what runs when the container starts.

Syntax:

EXPOSE

Example:

EXPOSE 3000

↗ Dockerfile

CMD

Definition: FROM picks the base image, WORKDIR sets the working folder, COPY adds files, RUN runs a command while building, EXPOSE documents a port and CMD is what runs when the container starts.

Syntax:

CMD

Example:

CMD ["node", "server.js"]

↗ Dockerfile

depends_on

Definition: depends_on sets the start order, and compose creates a shared network so services reach each other by service name (for example host db ).

Syntax:

depends_on

Example:

depends_on:

↗ Docker Compose

db

Definition: depends_on sets the start order, and compose creates a shared network so services reach each other by service name (for example host db ).

Syntax:

db

Example:

- db
db:

↗ Docker Compose

down

Definition: Useful commands: docker compose up -d (start in the background), docker compose ps (status), docker compose logs -f (follow logs), docker compose build (rebuild images) and docker compose down (stop and remove).

Syntax:

down

Example:

docker compose down

↗ Compose commands

Example code

docker --version

Run this code in the online editor

← Welcome to the Docker courseDocker introduction →