When I try to install homebrew on Ubuntu 18.04
# 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)"
getting errors:
==> Add Ruby to your PATH by running: PATH=/root/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/current/bin:$PATH Don't run this as root!
To know if Homebrew is correctly installed, we can install the test package called hello. Updating Homebrew... 1.- Install homebrew on Ubuntu / Debian Hello, world! With Homebrew you can install many useful programs, to have a complete list run: And you’ll see a long list. 3.- Search for programs to install using Homebrew
Step 1: Open the terminal of your local system and run the Ubuntu Docker Image from the Docker Registry. If your system has no previous pulls, it will start pulling from the registry. Step 2: Now, you have opened the bash of your Ubuntu Docker Container. To install any packages, you first need to update the OS.
1 Open the terminal of your local system and run the Ubuntu Docker Image from the Docker Registry. ... 2 Now, you have opened the bash of your Ubuntu Docker Container. To install any packages, you first need to update the OS. ... 3 After you have updated the Docker Container, you can now install the Firefox and Vim packages inside it.
However, it also has a version for Linux easy to install and use. Homebrew installs the programs in /usr/local and then makes a symbolic link to the binary folder. This means that it does not require sudo and does not affect the system.
Is there a reason you can't use the official image (docker pull linuxbrew/linuxbrew
)? It is based on Ubuntu 16.04 / Xenial.
If you must use Bionic (18.04), the correct way to install homebrew will be to follow the steps in the official Dockerfile.
But to get your Dockerfile working, you need to install ruby, create a non-root user and execute the installation script as that user. Like so,
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: I have added --no-install-recommends
to ignore optional dependencies and rm -rf /var/lib/apt/lists/*
to remove apt-get
leftovers thus reducing the image size. Also, locales
is added to install UTF-8 or brew
will throw a warning when you run the command.
The new correct way is:
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)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With