编写自定义镜像myubuntu

装备

root@ubuntu:/text# pwd
/text
root@ubuntu:/text# ll
total 12
drwxr-xr-x  2 root root 4096 May 13 06:56 ./
drwxr-xr-x 33 root root 4096 May 13 06:55 ../
-rw-r--r--  1 root root  321 May 13 06:56 Mydockerfile

编写文件

FROM ubuntu
MAINTAINER zzyy<zzyybs@126.com>
 
ENV MYPATH /usr/local
WORKDIR $MYPATH
 
RUN apt-get update
RUN apt-get install net-tools
#RUN apt-get install -y iproute2
#RUN apt-get install -y inetutils-ping
 
EXPOSE 80
 
CMD echo $MYPATH
CMD echo "install inconfig cmd into ubuntu success--------------ok"
CMD /bin/bash
  • 构建
docker build -t 新镜像名字:TAG .
  • 运行
docker run -it 新镜像名字:TAG

image-20220513221602143