I do some test in the docker which use clean ubuntu14.04. I use the below code to install ruby2.0 in the dockerfile:
RUN apt-add-repository ppa:brightbox/ruby-ng
RUN apt-get update && apt-get -y install \
ruby2.0 \
ruby2.0-dev
Then i enter the docker. The issue occur: when i use
apt-get install ruby2.0
there is no question. when i use
apt-get install ruby
after apt-get update, apt will find ruby1.9 to install and overwrite the link(/usr/bin/ruby), which means the default ruby version is 1.9 now.
For further development, i can not specify version. And also, i need to let this operation run well at ubuntu14.04 even i know it can pass at ubuntu16. How can i fix this issue?
And is the apt source in the docker different from ubuntu14.04?
The apt-add-repository
doesn't exist. And the official ubuntu:14.04 image doesn't include add-apt-repository
by default. You need to install it with
apt-get update && apt-get install software-properties-common
After this, you can install your ruby by,
add-apt-repository -y ppa:brightbox/ruby-ng
apt-get update && apt-get -y install ruby2.0 ruby2.0-dev
I am not sure how your Dockerfile can run without error. But there a tip for you to write a Dockerfile. Always run the command in the container first, before write it to the Dockerfile.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.