Dockerfile and dpkg command

27.3k views Asked by At

I'm trying to create a Dockerfile to install VuFind.

This is my Dockerfile:

#Name of container: docker-vufind:3

# Pull base image
FROM ubuntu:16.04
MAINTAINER xxx  "[email protected]"

#Install latest patches
RUN apt-get update && apt-get install -y \
    && apt-get install -y wget 

#Obtain the package
RUN wget http://downloads.sourceforge.net/vufind/vufind_3.1.1.deb?use_mirror=osdn -O vufind_3.1.1.deb

#Install it
RUN dpkg -i vufind_3.1.1.deb

#Install VuFind's dependecies
RUN apt-get install -y -f

I launched these commands on my Ubuntu's bash and the software worked fine, but it seems that I can't obtain the same result with the Dockerfile because the dpkg command failed for the lack of the dependencies.

The command '/bin/sh -c dpkg -i vufind_3.1.1.deb' returned a non-zero code: 1

Is installing the dependecies (Apache, jdk, php...) before the dpkg command line the only way to create a working Dockerfile or is there a shorter way ?

4

There are 4 answers

5
Cristian Todea On BEST ANSWER

Not the most elegant but:

# continue executing even if command fails
RUN dpkg -i vufind_3.1.1.deb || true
0
Saurabh Prakash On

Slightly more elegant.

# Run both commands together
RUN dpkg -i vufind_3.1.1.deb; apt-get install -y -f
1
Murmel On

With apt version 1.1~exp11 (which is available since Ubuntu 16.04), you are able to install .deb files and resolve dependencies directly with apt alone:

apt install ./vufind_3.1.1.deb

Mind the ./!

0
Anas Tiour On

Seems like a found a cleaner alternative, at least for my case. Since apt's CLI is not stable (as they warn during the Docker build), I opted to work with the package gdebi-core which can isntall .deb packages and its dependecies:

sudo apt-get install gdebi-core
sudo gdebi /path/to/filename.deb

Check this answer on Superuser for more details/