Docker Installation, Usage, and Image Customization Guide
This comprehensive guide explains how to install Docker CE on Ubuntu, manage system requirements, uninstall old versions, configure repositories, verify installation with the hello‑world image, manage Docker as a non‑root user, remove Docker, and customize images using docker commit and Dockerfiles, including best practices for building efficient multi‑layer images.
Docker is a revolutionary open‑source platform that greatly improves application deployment, testing, and distribution efficiency by leveraging container virtualization.
System requirements : Docker CE requires a 64‑bit Ubuntu version (Artful 17.10, Zesty 17.04, Xenial 16.04 LTS, Trusty 14.04 LTS) and supports architectures such as x86_64, armhf, s390x, and ppc64le.
Uninstall old versions (docker, docker‑engine): apt-get remove docker docker-engine Install Docker CE via repository :
apt-get update apt-get install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" apt-get update && apt-get install docker-ceVerify the installation with the test image: docker run hello-world The command pulls the hello-world:latest image, runs a container, and prints a success message.
Manage Docker as a non‑root user :
sudo groupadd docker sudo usermod -aG docker $USERLog out and back in, then you can run Docker commands without sudo: docker run hello-world Uninstall Docker CE :
sudo apt-get purge docker-ce sudo rm -rf /var/lib/dockerCustomize images with docker commit :
docker run --name myweb -d -p 80:80 nginx docker exec -it myweb bash echo '<h1>Welcome to Docker!</h1>' > /usr/share/nginx/html/index.html docker commit --author "penglei <[email protected]>" --message "Modified default page" myweb nginx:v2View the new image with docker image ls and its history with docker history nginx:v2.
Dockerfile‑based image building provides reproducible, layered images. A simple Dockerfile:
FROM nginx
RUN echo '<h1>Hello, Docker!</h1>' > /usr/share/nginx/html/index.htmlThe FROM instruction selects the base image (e.g., an official image or scratch for an empty base). The RUN instruction executes commands; multiple commands should be combined with && in a single RUN to minimize layers and keep images lean.
Build the image: docker build -t nginx:v3 . The build output shows each step, the intermediate container IDs, and the final image ID.
Advanced docker build usage includes building directly from a Git repository, a tarball URL, or standard input streams, allowing flexible CI/CD pipelines.
References: "Docker – From Beginner to Practice" and Docker official installation guide for Ubuntu.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Architect's Tech Stack
Java backend, microservices, distributed systems, containerized programming, and more.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
