Was setting up jekyll
using docker
, but was not able to install ruby on the docker machine as apt-add-repository
was not working.
Below is my Dockerfile
when I had the issue. Turns out that we need to install software-properties-common
before we can add an external repo.
Old Configuration Dockerfile
.
By default ubuntu installs 1.9
version of ruby
.
FROM ubuntu:xenial
LABEL maintainer "AHMED ZBYR <ahmedzbyr@gmail.com>"
# Set the working directory to /jekyll_application
WORKDIR /jekyll_application
# Copy the current directory contents into the container at /jekyll_application
ADD . /jekyll_application
RUN apt-get update
RUN apt-get dist-upgrade -y
RUN apt-get update
RUN apt-add-repository ppa:brightbox/ruby-ng
RUN apt-get update
ERROR on build.
Below is the error we get when we run. docker build -t ubuntu-jekyll .
/bin/sh: 1: add-apt-repository: not found
Solution For Issue.
Solution for this is, if you’re using Ubuntu 14.04 (Trusty) or newer then you can add the package repository like this:
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
Earlier version of Ubuntu 12.04 use.
$ sudo apt-get install python-software-properties
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
Updated Dockerfile.
Here is the updated Dockerfile
.
FROM ubuntu:xenial
LABEL maintainer "AHMED ZBYR <ahmedzbyr@gmail.com>"
# Set the working directory to /jekyll_application
WORKDIR /jekyll_application
# Copy the current directory contents into the container at /jekyll_application
ADD . /jekyll_application
RUN apt-get update
RUN apt-get dist-upgrade -y
RUN apt-get update
RUN apt-get -y install software-properties-common
RUN apt-add-repository ppa:brightbox/ruby-ng
RUN apt-get update
RUN apt-get install -y ruby2.4 ruby2.4-dev make gcc git