Skip to content

Commit a2c31e1

Browse files
author
qixianhu
committed
升级dockerfile 压缩包大小,去除Nginx,nodejs等。 v7.8.4
1 parent 17e4369 commit a2c31e1

1 file changed

Lines changed: 33 additions & 47 deletions

File tree

‎Docker/Dockerfile‎

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Dockerfile by xianhu: build a docker image
2-
# docker build --rm -t xianhu/centos:v7.8.3 .
2+
# docker build --rm -t xianhu/centos:v7.8.4 .
33

44
# 普通进入
5-
# docker run -it --name test [-p -v] xianhu/centos:v7.8.3 (ctrl+p/q即可退出,attach重新进入)
5+
# docker run -it --name test [-p -v] xianhu/centos:v7.8.4 /bin/bash
6+
# docker attach test (ctrl+p/q即可退出,attach重新进入)
67

78
# 特权进入
8-
# docker run -it --name test -d [-p -v] --privileged=true xianhu/centos:v7.8.3 /usr/sbin/init
9+
# docker run -it --name test [-p -v] -d --privileged=true xianhu/centos:v7.8.4
910
# docker exec -it test /bin/bash (不能使用attach进入,退出直接exit即可)
1011

1112
# 基础镜像
@@ -15,59 +16,44 @@ FROM centos:7.8.2003
1516
ENV LANG "en_US.UTF-8"
1617
ENV LC_ALL "en_US.UTF-8"
1718

18-
# change system local time
19-
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
20-
21-
# fix: warning: rpmts_HdrFromFdno
22-
RUN rpm --import /etc/pki/rpm-gpg/RPM*
19+
# change system local time, fix: warning: rpmts_HdrFromFdno
20+
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
21+
rpm --import /etc/pki/rpm-gpg/RPM*
2322

2423
# update yum and install something
25-
RUN yum update -y
26-
RUN yum install -y xz
27-
RUN yum install -y vim
28-
RUN yum install -y git
29-
RUN yum install -y gcc
30-
RUN yum install -y make
31-
RUN yum install -y wget
32-
RUN yum install -y which
33-
RUN yum install -y screen
34-
RUN yum install -y gcc-c++
35-
RUN yum install -y crontabs
36-
RUN yum install -y zlib-devel
37-
RUN yum install -y sqlite-devel
38-
RUN yum install -y openssl-devel
39-
RUN yum install -y bzip2-devel
40-
RUN yum install -y libffi-devel
41-
RUN yum install -y libSM.x86_64
42-
RUN yum install -y libXext.x86_64
43-
RUN yum install -y libXrender.x86_64
44-
45-
# install node
46-
RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash -
47-
RUN yum install -y nodejs
48-
49-
# install epel
50-
RUN yum install -y epel-release
24+
RUN yum update -y && \
25+
yum install -y xz \
26+
vim \
27+
git \
28+
gcc \
29+
make \
30+
wget \
31+
which \
32+
screen \
33+
gcc-c++ \
34+
crontabs \
35+
zlib-devel \
36+
sqlite-devel \
37+
openssl-devel \
38+
bzip2-devel \
39+
libffi-devel \
40+
libSM.x86_64 \
41+
libXext.x86_64 \
42+
libXrender.x86_64
5143

5244
# install python
53-
COPY ./Python-3.8.12.tgz /root
54-
WORKDIR /root
45+
COPY ./Python-3.8.12.tgz /root/
46+
WORKDIR /root/
5547
RUN tar xvzf Python-3.8.12.tgz
56-
WORKDIR /root/Python-3.8.12
57-
RUN ./configure
58-
RUN make && make install
59-
60-
# clean root
48+
WORKDIR /root/Python-3.8.12/
49+
RUN ./configure && make && make install
6150
WORKDIR /root/
62-
RUN rm -rf /root/*
6351

64-
# install nginx
65-
RUN yum install -y nginx
52+
# clean root and yum cache
53+
RUN rm -rf /root/* && yum clean all
6654

67-
# clean yum cache
68-
RUN yum clean all
6955
# RUN python3 -m pip install --upgrade pip -i http://pypi.douban.com/simple/
7056
# RUN python3 -m pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/
7157

7258
# entry
73-
CMD /bin/bash
59+
CMD /usr/sbin/init

0 commit comments

Comments
 (0)