<p>You need to learn a bit more about Debian or Ubuntu. If you look at every single Debian or Ubuntu container that installs things, you will notice, amongst other things:</p>

<pre><code>apt-get update &amp;&amp; apt -f install [whatever]
</code></pre>

<p>The reason for this is that aptitude doesn't know where to find anything without the "apt update".</p>

<p>See for example  <a href="https://github.com/dockerfile/ubuntu/blob/master/Dockerfile" rel="nofollow noreferrer">https://github.com/dockerfile/ubuntu/blob/master/Dockerfile</a></p>

<pre><code># Install.
RUN \
  sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list &amp;&amp; \
  apt-get update &amp;&amp; \
  apt-get -y upgrade &amp;&amp; \
  apt-get install -y build-essential &amp;&amp; \
  apt-get install -y software-properties-common &amp;&amp; \
  apt-get install -y byobu curl git htop man unzip vim wget &amp;&amp; \
  rm -rf /var/lib/apt/lists/*
</code></pre>

<p>This updates all packages, then installs build-essential, then software-properties-common and then the packages in the second to last line. Of course you don't need all of this. </p>

<p>It is important however to have the apt-get update &amp;&amp; apt-get install on the same line, if you are ever going to deploy your Dockerfile to any CI system. If apt-get update is on its own line, then that layer will never get invalidated as the succeeding layers will have old sources that they build consequent layers from. Keep in mind that every single command generates its own layer, that is why commands are chained in this way - so as to create one layer instead of many that will never serve any purpose. </p>

CC BY-SA 4.0
2019-05-10T15:28:53.517Z
2019-05-10T15:28:53.517Z
Dagelf
<p>While pear is down, the following instruction in my dockerfile is failing:</p>

<pre><code>RUN pear install -o --alldeps MDB2-beta &amp;&amp; \
</code></pre>

<p>I've searched on the internet how to install MDB2 without pear, successfully accomplished it by downloading the .deb file from <a href="https://packages.ubuntu.com/search?keywords=php-mdb2" rel="nofollow noreferrer">https://packages.ubuntu.com/search?keywords=php-mdb2</a> and then doing <code>dpkg -i php-mdb2_2.5.0b5-2_all.deb</code></p>

<p>My issue is that the same instructions are failing when placed in the dockerfile. Here's the instructions:</p>

<pre><code>RUN wget http://mirrors.edge.kernel.org/ubuntu/pool/universe/p/php-mdb2/php-mdb2_2.5.0b5-2_all.deb -O php-mdb2_2.5.0b5-2_all.deb
RUN dpkg -i php-mdb2_2.5.0b5-2_all.deb
</code></pre>

<p>Here's the error message:</p>

<blockquote>
  <p>dpkg: dependency problems prevent configuration of php-mdb2: php-mdb2
  depends on php-common; however: Package php-common is not installed.
  php-mdb2 depends on php-pear (>= 1.3.6); however: Package php-pear is
  not installed.</p>
</blockquote>

<p>I've tried to manually search and install all dependencies, and dependencies' dependencies but failed at the end because one of them is being told to me that it'll break locales thus cannot be installed.</p>

<p>Also tried another solution I found in stackOverflow to install dependencies for dpkg but it also fails. Instructions:</p>

<pre><code>RUN wget http://mirrors.edge.kernel.org/ubuntu/pool/universe/p/php-mdb2/php-mdb2_2.5.0b5-2_all.deb -O php-mdb2_2.5.0b5-2_all.deb
RUN dpkg -i php-mdb2_2.5.0b5-2_all.deb || true &amp;&amp; \
apt-get -f install
</code></pre>

<p>Error received:</p>

<blockquote>
  <p>dpkg: error processing package php-mdb2 (--install): dependency
  problems - leaving unconfigured Errors were encountered while
  processing: php-mdb2 Reading package lists... Building dependency
  tree... Reading state information... Correcting dependencies... Done
  The following packages will be REMOVED: php-mdb2 0 upgraded, 0 newly
  installed, 1 to remove and 9 not upgraded. 1 not fully installed or
  removed. After this operation, 528 kB disk space will be freed. Do you
  want to continue? [Y/n] Abort. ERROR: Service 'app' failed to build:
  The command '/bin/sh -c dpkg -i php-mdb2_2.5.0b5-2_all.deb || true &amp;&amp;
  apt-get -f install' returned a non-zero code: 1 Makefile:8: recipe for
  target 'build' failed make: *** [build] Error 1</p>
</blockquote>

<p>Can you point me in the right path maybe?</p>

<docker><php>
Install MDB2 in docker container while PEAR is down
Josafat
# Install MDB2 in docker container while PEAR is down

(Asked by: username_0 on 2019-01-28)

While pear is down, the following instruction in my dockerfile is failing:
RUN pear install -o --alldeps MDB2-beta && \

I've searched on the internet how to install MDB2 without pear, successfully accomplished it by downloading the .deb file from https://packages.ubuntu.com/search?keywords=php-mdb2 and then doing dpkg -i php-mdb2_2.5.0b5-2_all.deb
My issue is that the same instructions are failing when placed in the dockerfile. Here's the instructions:
RUN wget http://mirrors.edge.kernel.org/ubuntu/pool/universe/p/php-mdb2/php-mdb2_2.5.0b5-2_all.deb -O php-mdb2_2.5.0b5-2_all.deb
RUN dpkg -i php-mdb2_2.5.0b5-2_all.deb

Here's the error message:

dpkg: dependency problems prevent configuration of php-mdb2: php-mdb2
  depends on php-common; however: Package php-common is not installed.
  php-mdb2 depends on php-pear (>= 1.3.6); however: Package php-pear is
  not installed.

I've tried to manually search and install all dependencies, and dependencies' dependencies but failed at the end because one of them is being told to me that it'll break locales thus cannot be installed.
Also tried another solution I found in stackOverflow to install dependencies for dpkg but it also fails. Instructions:
RUN wget http://mirrors.edge.kernel.org/ubuntu/pool/universe/p/php-mdb2/php-mdb2_2.5.0b5-2_all.deb -O php-mdb2_2.5.0b5-2_all.deb
RUN dpkg -i php-mdb2_2.5.0b5-2_all.deb || true && \
apt-get -f install

Error received:

dpkg: error processing package php-mdb2 (--install): dependency
  problems - leaving unconfigured Errors were encountered while
  processing: php-mdb2 Reading package lists... Building dependency
  tree... Reading state information... Correcting dependencies... Done
  The following packages will be REMOVED: php-mdb2 0 upgraded, 0 newly
  installed, 1 to remove and 9 not upgraded. 1 not fully installed or
  removed. After this operation, 528 kB disk space will be freed. Do you
  want to continue? [Y/n] Abort. ERROR: Service 'app' failed to build:
  The command '/bin/sh -c dpkg -i php-mdb2_2.5.0b5-2_all.deb || true &&
  apt-get -f install' returned a non-zero code: 1 Makefile:8: recipe for
  target 'build' failed make: *** [build] Error 1

Can you point me in the right path maybe?

**Tags:** docker, php


---

## 1 answers

### Answer by username_1 on 2019-05-10. Score: 1

You need to learn a bit more about Debian or Ubuntu. If you look at every single Debian or Ubuntu container that installs things, you will notice, amongst other things:
apt-get update && apt -f install [whatever]

The reason for this is that aptitude doesn't know where to find anything without the "apt update".
See for example  https://github.com/dockerfile/ubuntu/blob/master/Dockerfile
# Install.
RUN \
  sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
  apt-get update && \
  apt-get -y upgrade && \
  apt-get install -y build-essential && \
  apt-get install -y software-properties-common && \
  apt-get install -y byobu curl git htop man unzip vim wget && \
  rm -rf /var/lib/apt/lists/*

This updates all packages, then installs build-essential, then software-properties-common and then the packages in the second to last line. Of course you don't need all of this. 
It is important however to have the apt-get update && apt-get install on the same line, if you are ever going to deploy your Dockerfile to any CI system. If apt-get update is on its own line, then that layer will never get invalidated as the succeeding layers will have old sources that they build consequent layers from. Keep in mind that every single command generates its own layer, that is why commands are chained in this way - so as to create one layer instead of many that will never serve any purpose.


---

