Mustafa CavusogluMC

Command Palette

Search for a command to run...

AboutExperiencesProjects
Linux3Docker3Git3uv1Miniconda1Kubernetes3
Back to Home
Docker

Building and managing Docker images

imagesbuilddockerfileregistry

Docker Images

Commands for building and managing Docker images.

Working with Images

# List images
docker images

# Pull an image
docker pull nginx:latest

# Remove an image
docker rmi nginx:latest

# Remove unused images
docker image prune

# Remove all unused images
docker image prune -a

Building Images

# Build from Dockerfile
docker build -t my-image:tag .

# Build with different Dockerfile
docker build -f Dockerfile.prod -t my-image:prod .

# Build with build arguments
docker build --build-arg VERSION=1.0 -t my-image .

# Build without cache
docker build --no-cache -t my-image .

Example Dockerfile

FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --only=production

COPY . .

EXPOSE 3000

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

Registry Operations

# Login to registry
docker login

# Tag image for registry
docker tag my-image:latest registry.example.com/my-image:latest

# Push to registry
docker push registry.example.com/my-image:latest

# Pull from registry
docker pull registry.example.com/my-image:latest