Skip to content

Commit 99145ce

Browse files
qiluo-msftMichelMoriniaux
authored andcommitted
Remove unused packages in docker images and host (sonic-net#2807)
* Remove unneeded packages in docker images and host * Remove libpython3.6 from snmp docker image
1 parent b73af5e commit 99145ce

File tree

9 files changed

+16
-10
lines changed

9 files changed

+16
-10
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-stretch/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-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
@@ -35,7 +35,7 @@ RUN pip install /python-wheels/{{ whl }}
3535
{% endif %}
3636

3737
# Clean up
38-
RUN apt-get remove -y python-pip
38+
RUN apt-get purge -y python-pip
3939
RUN apt-get clean -y
4040
RUN apt-get autoclean -y
4141
RUN apt-get autoremove -y

dockers/docker-platform-monitor/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ RUN pip install /python-wheels/{{ whl }}
4646
{% endif %}
4747

4848
# Clean up
49-
RUN apt-get remove -y python-pip
49+
RUN apt-get purge -y python-pip
5050
RUN apt-get clean -y
5151
RUN apt-get autoclean -y
5252
RUN apt-get autoremove -y

dockers/docker-snmp-sv2/Dockerfile.j2

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

6262
# Clean up
63-
RUN apt-get -y purge libpython3.6-dev curl gcc make libdpkg-perl
63+
RUN apt-get -y purge libpython3.6-dev libpython3.6 curl gcc make libdpkg-perl
64+
# Note: these packages should be removed with autoremove but actually not, so explicitly purged
65+
RUN apt-get -y purge libldap-2.4-2 libsasl2-2 libsasl2-modules libsasl2-modules-db
6466
RUN apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y --purge
6567
RUN find / | grep -E "__pycache__" | xargs rm -rf
6668
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
@@ -311,7 +311,7 @@ sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
311311
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/
312312
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable snmp.timer
313313

314-
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get remove -y python-dev
314+
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-dev
315315
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y
316316
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get autoremove -y
317317

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)