Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Docker Fundamentals: Core Command Line Operations

Tech May 7 4

Inspecting Resources

Viewing Image Repositories

Retrieve a list of all image objects available locally.

docker images --all

Monitoring Active Containers

List currently running instances to verify status and obtain identifiers.

docker ps -a

The output displays the Container ID in the first column, which is required for subsequent operations.

Mdoifying Images

Committing Runtime Changes

Capture the current state of a container as a new image artifact. This is useful for saving temporary configurations or dependencies.

docker commit \
  -m="Applied security patches" \
  --author "dev-team@example.com" \
  container-7f8a9b0c custom-app:v2.1

Parameters:

  • -m: Description string summarizing changes.
  • --author: Email or name identifying the creator.
  • container-id: Target idantifier from an active container.
  • image-name:tag: Destination name and version tag for the new image.

Lifecycle Management

Instantiating Instances

Launch a new process based on a specific image with configuration overrides.

docker run -d \
  --name web-service \
  -v /opt/data:/var/www/html \
  -p 3000:80 \
  python:3.9-slim \
  tail -f /dev/null

Configuration Breakdown:

  • -d: Detached mode (runs in background).
  • --name: Assigns a human-readable alias (web-service).
  • -v: Bind mounts host directory /opt/data into container path /var/www/html.
  • -p: Maps host port 3000 to container port 80.
  • Image reference python:3.9-slim specifies the base environment.

Interactive Access

Enter the shell of a running instance for debugging or administration.

docker exec -it web-service bash

Termination and Removal

Stop a specific instance and purge its filesystem data.

docker stop web-service
docker rm web-service

Image Tagging and Cleanup

Renaming References

Update tags without duplicating underlying layers.

docker tag old-repo/app:v1 latest-staging/app:v1

Removing Artifacts

Force delete a untagged or referenced image layer.

docker rmi -f old-repo/app:v1

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.