Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker build fails on `add-apt-repository: not found`

My docker build fails on:

 ---> Running in a0d2edd6bf20
/bin/sh: 1: add-apt-repository: not found    
The command '/bin/sh -c add-apt-repository ppa:jonathonf/ffmpeg-3 && apt-get update && apt install -y libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev libavresample-dev ffmpeg libav-tools x264 x265' returned a non-zero code: 127

I've researched the problem and it says to install either software-properties-common or python-software-properties

I did just that but the error still persists. Here is my Dockerfile up until that point

FROM ubuntu:16.04

ENV HOME_DIR=/root

WORKDIR $HOME_DIR

RUN apt-get update && apt-get install -y \
    pkg-config \
    git \
    cmake \
    build-essential \
    nasm \
    wget \
    python3-setuptools \
    libusb-1.0-0-dev  \
    python3-dev \
    python3-pip \
    python3-numpy \
    python3-scipy \
    libglew-dev \
    libglfw3-dev \
    libtbb-dev \
    software-properties-common \
    python-software-properties 

RUN add-apt-repository ppa:jonathonf/ffmpeg-3 && \
    apt-get update && \
    apt install -y \
    libavformat-dev \
    libavcodec-dev \
    libavdevice-dev \
    libavutil-dev \
    libswscale-dev \
    libavresample-dev \
    ffmpeg \
    libav-tools \
    x264 \
    x265
like image 555
wprins Avatar asked Nov 07 '22 16:11

wprins


1 Answers

You can build an image using the current Dockerfile you have. I am assuming you are having an issue when you try to build 2 separate images.

That is because add-apt-repository will not be recognizable until there is software-properties-common or python-software-properties installed.

If both the runs are in a Dockerfile and you build an image using
docker build -t mydockerimage .
You will not see any issue because the second layer/run will build on top of the first, so the add-apt-repository is recognizable and you will not have any issue.

I hope this answers your query.

like image 194
Pradeep Ravilla Avatar answered Nov 14 '22 23:11

Pradeep Ravilla