Docker build stops on software-properties-common when run with `apt update` - docker

I have 2 dockerfiles:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y \
software-properties-common \
python3
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-get update && apt-get install -y \
python3
The thing is: when I run the first of them (with docker build) the build process hangs on:
The software-properties-common package is asking me about the geographical area - I cannot provide any input, it is not allowed when building images, I suppose.
However, when I build the second dockerfile, this problem does not occur. I'm curious - why is that?

Add the following line in your Dockerfile and build again.
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata

I found that running
ln -fs /usr/share/zoneinfo/UTC /etc/localtime
before setting DEBIAN_FRONTEND=noninteractive worked for me. (You'd want to replace the bit after zoneinfo with whatever is applicable for you.)
If you need it to be set dynamically, [this answer] (https://stackoverflow.com/a/63153978/1995015) suggests calling out to a website that can provide that.

Related

why multi-line command will make smaller size than single-line when i use yum install in Dockerfile

I have 2 Dockerfile.
First is
FROM centos:7
RUN yum update -y && \
yum install -y kde-l10n-Chinese && \
yum install -y glibc-common
and other is
FROM centos:7
RUN yum update -y
RUN yum install -y kde-l10n-Chinese
RUN yum install -y glibc-common
the docker image i get is like:
It bothers me, the official documentation says because of the number of layers, but I understand that each layer reuses the previous one, so there's no reason they should be 300mb different。
I would appreciate it if anyone could look into this problem for me. thank you.
when i use dive level:multi, it show me like:
the module i use is like: (excluded unmodified file)

Man pages not being installed in python docker image [duplicate]

I use the following Dockerfile to build an image and start a container. But once I am in the container, I still can not find manpages. Does anybody know how to solve this problem?
$ cat Dockerfile
FROM ubuntu
RUN apt -y update && apt -y upgrade
RUN apt-get -y install build-essential
RUN apt-get -y install vim
RUN apt-get -y install man
RUN apt-get -y install gawk
RUN apt-get -y install mawk
$ man man
No manual entry for man
See 'man 7 undocumented' for help when manual pages are not available.
$ find /usr/share/man /usr/local/share/man -type f
You need to make a change to your /etc/dpkg/dpkg.cfg.d/excludes within the container. You can do this in your Dockerfile with the following command:
RUN sed -i 's:^path-exclude=/usr/share/man:#path-exclude=/usr/share/man:' \
/etc/dpkg/dpkg.cfg.d/excludes
Then make another update to your Dockerfile to install the man pages
RUN apt-get update && \
apt-get install -y \
man \
manpages-posix
There is a easier way to enable the MAN command.
In terminal, just execute the command below:
unminimize
It will ask if you like to continue [Y/n]
Just press:
Y
It will take a while to finish all the processing.
After that, test this:
man man
Simple as that
Thanks to #kazushi

Cannot install php, apache and postgres on ubuntu base image in dockerfile

I started studying docker recently and wanted to install php, apache and postgres in a ubuntu base image. But cannot run it after build.
Here is my Dockerfile
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get -qq -y install curl
RUN apt-get -y install apache2
RUN apt-get -y install php7.0
RUN apt-get -y install libapache2-mod-php7.0
RUN apt-get -y install php7.0-mysql
RUN apt-get -y install php7.0-pgsql
RUN apt-get -y install php7.0-gd
RUN apt-get -y install php-pear
RUN apt-get -y install php7.0-curl
COPY . /var/www/html
EXPOSE 80
Can you please help me?
Thanks.
there are several issues here. First of all, I have the impression that you're mixing up docker and virtual machines. For this I suggest to go and read what are the differences.
Concerning your question, the problem is that the base image (ubuntu:16.04) has CMD bash (or something similar, I really didn't check) and therefore php is not considered.
In order to start apache, you should append the following:
CMD . /etc/apache2/envvars && /usr/sbin/apache2ctl -DFOREGROUND
Anyway, I'd suggest you give a check to the php official image.

How to convert an Ubuntu package/repository to Alpine in a Dockerfile?

Currently I have this Dockerfile
FROM ubuntu:18.04
# https://github.com/tesseract-shadow/tesseract-ocr-re
RUN apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:alex-p/tesseract-ocr
RUN apt-get update && apt-get install -y tesseract-ocr-all
RUN apt-get install -y git build-essential cmake
RUN apt-get install -y ffmpeg
# Install Node and NPM
RUN apt-get install nodejs -y && apt-get install npm -y
The size of the image is too big so I searched for alternatives and found about Alpine.
I'm stuck with this one
FROM alpine
RUN apk add --update ffmpeg cmake nodejs npm
Looking at the aline edge repository, I can't seem to find tesseract-ocr-all and no idea how to do apt-get install -y software-properties-common && add-apt-repository -y ppa:alex-p/tesseract-ocr in alpine.
Are there any resources that can help me through this? Should I make my own Alpine image for those packages/repositories?
The alpine package name is tesseract-ocr, you can check here the releases or alpine repository.
FROM alpine
RUN apk add --update --no-cache ffmpeg cmake nodejs npm tesseract-ocr
If you are interested in the beta version you may check here.
Always try to add --no-cache option allows to not cache the index locally, which keeps containers small.

How can I install ffmpeg to my docker image

I have setup a docker image in my Windows 10 Machine.
Can you please tell me how can I install ffmpeg to that docker image?
apt-get install ffmpeg
As of 2019, this seems to work, just fine on Docker.
Dockerfile
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y ffmpeg
In your dockerfile you can write this command to add required repo, update your repository and then install ffmpeg.
Though I am not sure if this library still exist I just modified this Link for Docker you can follow same rules to install another package.
RUN set -x \
&& add-apt-repository ppa:mc3man/trusty-media \
&& apt-get update \
&& apt-get dist-upgrade \
&& apt-get install -y --no-install-recommends \
ffmpeg \
If you stop with select of geographic area on Ubuntu 18.04 or above, you can install it by specifying ENV DEBIAN_FRONTEND=noninteractive as shown below.
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y ffmpeg
As of July 2022, this works for Dockerfile, well at least it worked for me.
RUN apt-get -y update && apt-get -y upgrade && apt-get install -y --no-install-recommends ffmpeg
Just to let the community know.

Resources