前言
最近需要回顾一下Linux环境的Bash命令。使用 Docker 是快速搭建 Linux 环境的最佳方式,只需运行以下命令即可获取并启动一个 Ubuntu 容器:
docker pull ubuntu
docker run -it ubuntu
然而,Docker Hub 提供的官方 Ubuntu 镜像是一个最小化版本(minimized version)。该镜像专为应用程序部署设计,仅包含必要的运行文件,删除了许多用于交互的软件包。例如,当运行 man 命令时,会提示:
This system has been minimized by removing packages and content that are not required on a system that users do not log into.
To restore this content, you can run the ‘unminimize’ command.
root@6ac67a73f171:/# man man
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, including manpages, you can run the ‘unminimize’
command. You will still need to ensure the ‘man-db’ package is installed
为了提升交互体验,我们将在官方 Ubuntu 最小镜像的基础上,安装必要的软件包,构建一个可用于日常操作的 Ubuntu 镜像。
使用dockerfile
Dockerfile内容如下:
ARG TAG
From ubuntu:$TAG
# set up DEBIAN_FRONTEND to avoid configuring tzdata
ENV DEBIAN_FRONTEND noninteractive
# 运行unminimize命令
RUN apt-get update && apt-get install -y unminimize && yes | unminimize
# 安装以下文件包:
# - vim编辑文件
# - man命令使用指南
# - iproute2 is the modern replacement for the old net-tools package and is the standard for network management in modern Linux distributions. It includes commands eg. ss, ip
# - netcat
# - python v3
RUN apt-get install