Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Last active April 16, 2024 19:57
Show Gist options
  • Save rwcitek/c4713166b0a2f14ad89cc375113572bf to your computer and use it in GitHub Desktop.
Save rwcitek/c4713166b0a2f14ad89cc375113572bf to your computer and use it in GitHub Desktop.
Installing and running Homebrew under Ubuntu in Docker

Installing and running Homebrew under Ubuntu in Docker

Reference

https://docs.brew.sh/Homebrew-on-Linux

Create an image

<< 'eof' docker image build --tag homebrew -f- .
FROM ubuntu:22.04
SHELL ["/bin/bash", "-c"]
RUN export DEBIAN_FRONTEND=noninteractive ; \
    apt-get update && \
    apt-get install -y \
      build-essential \
      curl \
      file \
      git \
      procps \
      ;
RUN yes | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
RUN ( echo ; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /root/.profile;

WORKDIR /root/

eof

Run a brew instance in the background

docker container run -d -i --name brew homebrew sleep inf

Install a brew

docker container exec -i brew /bin/bash -c 'source ~/.profile ; brew install hello'

Run a brew

docker container exec -i brew /bin/bash -c 'source ~/.profile ; hello'

NOTE: I'm not liking having to source the ~/.profile each time. That should be automatic. Will tackle another time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment