Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Essential Docker Command Reference

Tech 1

Build a image from Dockerfile:

docker build -t app-image:latest .

Export image to archive:

docker save -o backup.tar app-image:latest

Import image from archive:

docker load -i backup.tar

Run container with parameters:

docker run -d \\
  --name web-service \\
  -p 8080:80 \\
  -v /host/logs:/container/logs \\
  --net bridge \\
  --platform linux/amd64 \\
  app-image:latest

Network Configuration

Network modes:

  • bridge: Isolated network stack (default)
  • host: Shares host's network namespace
  • none: Disables networking

Check image platform:

docker inspect --format '{{.Os}}/{{.Architecture}}' app-image:latest

Buildx Multi-Platform Tool

Initialize builder:

docker buildx create --name multiarch-builder
 docker buildx use multiarch-builder
 docker buildx inspect --bootstrap

Build and push multi-arch image:

docker buildx build \\
  -t registry/app-image:multi \\
  --platform linux/amd64,linux/arm64 \\
  --push .

Core Operations

  • docker pull [repo/image]: Retrieve image
  • docker push [repo/image]: Upload image
  • docker images: List local images
  • docker rmi [image]: Delete image
  • docker run [options] [image]: Create container
  • docker stop [container]: Halt container
  • docker start [container]: Resume container
  • docker restart [container]: Recycle container
  • docker rm [container]: Remove container
  • docker ps: Show active containers
  • docker logs [container]: View output stream
  • docker exec -it [container] sh: Access shell
  • docker inspect [target]: Show metadata

Autostart configuration:

systemctl enable docker
docker update --restart unless-stopped [container]

Volume Commands

  • docker volume create [name]: Provision storage
  • docker volume ls: Enumerate volumes
  • docker volume rm [volume]: Delete volume
  • docker volume inspect [volume]: Show properties
  • docker volume prune: Purge unused volumes

Network Commands

  • docker network create [name]: Establish network
  • docker network ls: List networks
  • docker network rm [network]: Remove network
  • docker network prune: Clean unused networks
  • docker network connect [net] [container]: Attach container
  • docker network disconnect [net] [container]: Detach container
  • docker network inspect [network]: Show topology

Network example:

docker network create app-net
docker network connect app-net db-container --alias sql-db
docker network connect app-net api-container

Containers in custom networks communicate via aliases or names.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.