Dockerfile and dpkg command
Asked Answered
N

4

14

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 ?

Nuggar answered 16/12, 2016 at 9:6 Comment(1)
Just a quick FYI, but you can ignore the wget install and use the cmd `ADD http:\\path\to\file.txt file.txt'Borrell
Q
12

Not the most elegant but:

# continue executing even if command fails
RUN dpkg -i vufind_3.1.1.deb || true
Quindecennial answered 16/12, 2016 at 11:5 Comment(5)
Isn't the last line unnecessary? I.e. apt-get install -f would also install previously attempted deb package.Fiji
Indeed, last line is not needed anymore. Everything should be solved after second command.Maxson
Ain't there a way to run dpkg -i package.deb with dependencies in one command instead of having to run apt-get install -f afterwards, which is ugly and annoying?Conundrum
@AugustinRiedinger dpkg is not able to resolve dependencies because it only manages packages, not repositories (like yum or apt)Quindecennial
I'm not sure why the line apt-get install -y -f was removed. Perhaps it was something specific to a later version of VuFind. I came here trying to install dependencies for wkhtmltopdf because dpkg -i ... was saying dpkg: dependency problems prevent configuration of wkhtmltox: wkhtmltox depends on fontconfig; however: Package fontconfig is not installed... , etc. The line apt-get install -y -f installed all dependencies. Thanks!Hagar
M
12

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 ./!

Martlet answered 22/8, 2017 at 9:50 Comment(1)
Thank you! This is gold. And they same apt has nothing new except the fancy loading bar :DSober
C
3

Slightly more elegant.

# Run both commands together
RUN dpkg -i vufind_3.1.1.deb; apt-get install -y -f
Colossians answered 14/5, 2020 at 13:37 Comment(0)
S
1

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/

Sober answered 14/6, 2019 at 17:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.