当我尝试在Ubuntu 18.04上进行install自酿
# Dockerfile
FROM ubuntu:18.04
RUN apt-get update && apt-get install build-essential curl file git -y
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
得到错误:
==>通过运行以下命令将Ruby添加到您的PATH:PATH = / root / .linuxbrew / Homebrew / Library / Homebrew / vendor / portable-ruby / current / bin:$ PATH 不要以超级用户身份运行它!
答案 0 :(得分:2)
是否有不能使用official image(docker pull linuxbrew/linuxbrew
)的原因?它基于Ubuntu 16.04 / Xenial。
如果必须使用Bionic(18.04),则安装自制软件的正确方法是按照官方的Dockerfile中的步骤进行操作。
但是要使Dockerfile正常工作,您需要安装ruby,创建一个非root用户并以该用户身份执行安装脚本。像这样
FROM ubuntu:18.04
RUN apt-get update && \
apt-get install build-essential curl file git ruby-full locales --no-install-recommends -y && \
rm -rf /var/lib/apt/lists/*
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
RUN useradd -m -s /bin/bash linuxbrew && \
echo 'linuxbrew ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers
USER linuxbrew
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
USER root
ENV PATH="/home/linuxbrew/.linuxbrew/bin:${PATH}"
PS:我添加了--no-install-recommends
来忽略可选的依赖项,并添加了rm -rf /var/lib/apt/lists/*
来删除apt-get
的剩余部分,从而减小了图像的大小。另外,添加了locales
以安装UTF-8,或者运行该命令时brew
会发出警告。
答案 1 :(得分:2)
新的正确方法是:
RUN apt-get update && \
apt-get install -y -q --allow-unauthenticated \
git \
sudo
RUN useradd -m -s /bin/zsh linuxbrew && \
usermod -aG sudo linuxbrew && \
mkdir -p /home/linuxbrew/.linuxbrew && \
chown -R linuxbrew: /home/linuxbrew/.linuxbrew
USER linuxbrew
RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
答案 2 :(得分:2)
Gabriel的回答大部分对我有用,但缺少一步。我需要将chown
文件夹/home/linuxbrew/.linuxbrew
运到将要运行Homebrew的用户:
USER root
RUN chown -R $CONTAINER_USER: /home/linuxbrew/.linuxbrew