11

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.

1
  • 1
    Well... it's minimised for a reason, as pointed out below. Having said that, I've built server images from both minimized and unminimized bases, and the minimized version saves you very little, and can cause inconvenience with missing packages that really should be on an unattended server. On 22.04, the disk size saving is not much over 10%, and I've seen no noticeable difference in security updates.
    – EML
    Apr 1 at 9:44

3 Answers 3

11

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.

8

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
  • Seems really bad to me that I can't even get man pages to work by installing them. I don't want to install some unknown list of maximal or even unminimal stuff. I just want man pages to work. Is it really one monolithic thing? I don't think that is a good choice.
    – nroose
    Jul 14, 2020 at 15:54
  • Usually you don't run any debugging or testing in this kind of minimal docker images, and you don't need to read man page. If you do want to do that kind of things, get a "normal" image to work, then when you are ready to deploy, switch to minimal image (and test it well before release)
    – Ben L
    Dec 27, 2021 at 21:38
  • 1
    Ubuntu does not seems to provide any -minimal images any more, they are all minimized, see e.g. bugs.launchpad.net/ubuntu/+source/dpkg/+bug/1960749 Feb 13, 2022 at 20:48
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .