19

Today I noticed a new message when I login to my Ubuntu 18.04 docker container.

This system has been minimized by removing packages and content that are not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.

This is however a container that I log into from time to time.

IMHO it is not a very sound strategy to change systems without user consent in this way but that leaving that aside for the moment, how I can prevent Ubuntu from minimizing my systems?

The minimization breaks functionality of my container and the unminimize command ends with an kernel error.

onknows
  • 380

4 Answers4

20

Answering, because I don't have reputation to comment.

Although you can't technically prevent your Docker-based installation of Ubuntu from being minimized (because the Docker image comes that way when you pull it), you can definitely undo it: add an invocation of

yes | unminimize

to your Dockerfile. The "unminimize" command (/usr/local/sbin/unminimize) undoes the minimization process; because it's interactive, and asks a number of "y/n" questions, we use the "yes" command, which continually prints the string "y" until killed.

phlummox
  • 301
9

It's not that Canonical changed the image without users' consent. What you get is the prepackaged ubuntu-minimal which is used by most cloud hosting providers and containers like Docker.

You can read more about what is Minimal Ubuntu.

Quote for context:

Minimal Ubuntu is a set of Ubuntu images designed for automated deployment at scale and made available across a range of cloud substrates. They use the optimised kernels and optimised boot process on their target compute substrate. These images have a greatly reduced default package set, without many convenience tools for interactive usage. They are much smaller, boot faster, and will require fewer security updates over time since they have fewer packages installed.

To answer your question - you have more than one choice:

  1. Use something other than ubuntu-minimal as a base image
  2. Customize the image to include the packages you need
3

To prevent from being minimized docker ubuntu images, I have written a dockerfile. Kindly deploy container using below dockerfile content.

From ubuntu
#Purpose: How to deploy ubuntu container without minimized packages
#RUN apt-get install apt-utils -y
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=Asia/Kolkata DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt install tzdata -y && apt install net-tools vim man file -y
RUN yes| unminimize
RUN apt-get update -y && apt-get upgrade -y && apt-get install ubuntu-minimal ubuntu-server-minimal -y
RUN  apt-get install -y vim perl wget tar man sudo adduser netstat-nat net-tools curl w3m
RUN useradd -m  -s /bin/bash ubuntu
RUN usermod -aG sudo ubuntu && echo "ubuntu ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ubuntu
RUN chmod 044 /etc/sudoers.d/ubuntu
USER ubuntu:ubuntu
WORKDIR /home/ubuntu
CMD ["/bin/bash"]
#docker run -itd --privileged #type_here_target_image_id /usr/sbin/init #command to run systemctl inside docker container
Mr. Linux
  • 195
  • 5
1

ubuntu 24.04

has no unminimize by default

here is how to fix it:

apt-get update -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y unminimize \
&& rm -rf /var/lib/apt/lists/* \
&& yes | /usr/local/sbin/unminimize

related bug report

smido
  • 185