Docker Community Forums

Share and learn in the Docker community.

Errow while trying to install ruby on Dockerfile


(Mertcancam) #1

This is the inside of my Docker file;

FROM ubuntu:xenial

    MAINTAINER Jose Mota <>

    # Just use bash.
    RUN rm /bin/sh && ln -s /bin/bash /bin/sh

    # Debian complains about the terminal environment on Docker. Use this.
    RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

    # Install base packages
    RUN apt-get update
    RUN apt-get upgrade -y
    RUN apt-get install -y curl wget ca-certificates build-essential autoconf python-software-properties libyaml-dev

    # Install nginx repositories
    RUN wget
    RUN apt-key add nginx_signing.key
    RUN echo "deb trusty nginx" >> /etc/apt/sources.list.d/nginx.list
    RUN echo "deb-src trusty nginx" >> /etc/apt/sources.list.d/nginx.list

    # Finish installing remaining dependencies
    RUN apt-get update -y
    RUN apt-get install -y libssl-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev bison openssl make git libpq-dev libsqlite3-dev nodejs nginx
    RUN apt-get clean

    # Force sudoers to not being asked the password
    RUN echo %sudo        ALL=NOPASSWD: ALL >> /etc/sudoers

    # Ruby-install
    RUN wget -O ruby-install-0.5.0.tar.gz && tar -xzvf ruby-install-0.5.0.tar.gz && cd ruby-install-0.5.0/ && make install

    # chruby
    RUN wget -O chruby-0.3.9.tar.gz && tar -xzvf chruby-0.3.9.tar.gz && cd chruby-0.3.9/ && make install

    RUN rm -rf /var/cache/apt/* /tmp/*

    # Add a user just for running the app
    RUN useradd -m -G sudo app

    USER app
    WORKDIR /home/app

    # Install a Ruby version
    RUN ruby-install ruby
    RUN rm -rf /home/app/src

Error that i am facing when i run sudo docker build .

Installing ruby 2.1.3 into /home/app/.rubies/ruby-2.1.3 …
Installing dependencies for ruby 2.1.3 …
/usr/local/bin/…/share/ruby-install/ line 104: sudo: command not found
!!! Installing dependencies failed!
The command ‘/bin/sh -c ruby-install ruby’ returned a non-zero code: 255


(Nathan Le Claire) #2
 sudo: command not found

Did you read your error message?

sudo program is not installed within the container. Usually this is fixable by just dropping the sudo since containers run as root by default, but looks like you’re depending on another program which needs it.

apt-get install sudo before attempting to invoke it.