dockerfile制作Ubuntu基础镜像
apt源文件内容
[root@localhost ubuntu]# cat sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
dockerfile
[root@localhost ubuntu]# cat Dockerfile
#dockerfile ubuntu-base is image
FROM ubuntu:18.04
LABEL mail=timerovers@163.com
ENV LANG="zh_CN.utf8"
#apt源
COPY sources.list /etc/apt/sources.list
#时区
RUN apt update \
&& apt -y install tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& apt install -y language-pack-zh-hans \
&& apt-get clean
构建以及启动
docker build -t ubuntu-base:18.04 .
docker run -d -it --name ubuntu-base ubuntu-base:18.04 bash
大小
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu-base 18.04 c33ef0a9250b 30 seconds ago 127MB