Skip to content

Commit dd31c2d

Browse files
qiluo-msftyxieca
authored andcommitted
Remove unused packages in docker images and host (#2807)
* Remove unneeded packages in docker images and host * Remove libpython3.6 from snmp docker image
1 parent e4a663a commit dd31c2d

File tree

8 files changed

+15
-9
lines changed

8 files changed

+15
-9
lines changed

dockers/docker-base/Dockerfile.j2

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ RUN apt-get -y install {{ dbg_pkg }}
7373
RUN ln /usr/bin/vim.tiny /usr/bin/vim
7474
{%- endif %}
7575

76+
# Remove python3.4
77+
# Note: if later python3 is required by more docker images, consider install homebrew python3 here instead of in SNMP image only
78+
RUN apt-get purge -y libpython3.4-minimal
79+
7680
# Clean up apt
7781
# Remove /var/lib/apt/lists/*, could be obsoleted for derived images
7882
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y

dockers/docker-config-engine/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ python-wheels/{{ whl }}{{' '}}
4343
{%- endif -%}
4444

4545
## Clean up
46-
RUN apt-get remove -y python-pip python-dev; apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
46+
RUN apt-get purge -y python-pip python-dev; apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
4747
RUN rm -rf /debs /python-wheels

dockers/docker-lldp-sv2/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN pip install /python-wheels/{{ whl }}
3737
{% endif %}
3838

3939
# Clean up
40-
RUN apt-get remove -y python-pip
40+
RUN apt-get purge -y python-pip
4141
RUN apt-get clean -y
4242
RUN apt-get autoclean -y
4343
RUN apt-get autoremove -y

dockers/docker-platform-monitor/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN pip install /python-wheels/{{ whl }}
3737
{% endif %}
3838

3939
# Clean up
40-
RUN apt-get remove -y python-pip
40+
RUN apt-get purge -y python-pip
4141
RUN apt-get clean -y
4242
RUN apt-get autoclean -y
4343
RUN apt-get autoremove -y

dockers/docker-snmp-sv2/Dockerfile.j2

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ RUN pip install /python-wheels/{{ whl }}
5656
RUN python3.6 -m sonic_ax_impl install
5757

5858
# Clean up
59-
RUN apt-get -y purge libpython3.6-dev curl gcc make
59+
RUN apt-get -y purge libpython3.6-dev libpython3.6 curl gcc make
60+
# Note: these packages should be removed with autoremove but actually not, so explicitly purged
61+
RUN apt-get -y purge libldap-2.4-2 libsasl2-2 libsasl2-modules libsasl2-modules-db
6062
RUN apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y --purge
6163
RUN find / | grep -E "__pycache__" | xargs rm -rf
6264
RUN rm -rf /debs /python-wheels ~/.cache

dockers/docker-sonic-mgmt/Dockerfile.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ RUN apt-get install -y default-jre
2929
RUN apt-get install -y rsyslog psmisc
3030

3131
# Remove cffi 1.5.2, will install 1.10.0 by pip later
32-
RUN apt-get remove -y python-cffi python-cffi-backend
32+
RUN apt-get purge -y python-cffi python-cffi-backend
3333
# Remove pycparser 2.14, will install >=2.17 by pip later
34-
RUN apt-get remove -y python-ply python-pycparser
34+
RUN apt-get purge -y python-ply python-pycparser
3535

3636
RUN easy_install pip
3737

files/build_templates/sonic_debian_extension.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
309309
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/
310310
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable snmp.timer
311311

312-
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get remove -y python-dev
312+
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-dev
313313
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y
314314
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get autoremove -y
315315

rules/python3.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ $(PY3_MIN)_RDEPENDS += $(LIBPY3_MIN)
2626

2727
PY3 = $(PYTHON_PNAME)_$(PYTHON_VER)_amd64.deb
2828
$(eval $(call add_derived_package,$(LIBPY3_MIN),$(PY3)))
29-
$(PY3)_DEPENDS += $(PY3_MIN) $(LIBPY3)
30-
$(PY3)_RDEPENDS += $(PY3_MIN) $(LIBPY3) $(LIBPY3_MIN)
29+
$(PY3)_DEPENDS += $(PY3_MIN) $(LIBPY3_STD)
30+
$(PY3)_RDEPENDS += $(PY3_MIN) $(LIBPY3_STD)
3131

3232
LIBPY3_DEV = lib$(PYTHON_PNAME)-dev_$(PYTHON_VER)_amd64.deb
3333
$(eval $(call add_derived_package,$(LIBPY3_MIN),$(LIBPY3_DEV)))

0 commit comments

Comments
 (0)