# Docker for MacOS with Homebrew

**URL:** <https://www.rubin.community/t/docker-for-macos-with-homebrew/2759>\
**Category:** Support\
**Tags:** mac, docker\
**Created:** [March 13, 2018, 5:02pm UTC](https://www.rubin.community/t/docker-for-macos-with-homebrew/2759 "2018-03-13T17:02:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![price](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/price/32/488_2.png) [@price](https://www.rubin.community/u/price)\
**Post date:** [March 13, 2018, 5:02pm UTC](https://www.rubin.community/t/docker-for-macos-with-homebrew/2759/1 "2018-03-13T17:02:29Z")

</div>

I haven’t updated the stack build on my Mac for quite some time, as it takes a while. However, I’ve been wanting more recent images for developing on master, and I’d like to be able to stay up to date with the stack without much effort, so when @mwv mentioned some Docker problems in Slack, it triggered an interest in getting that working on my Mac.

I use Homebrew on my Mac, and prefer to use that instead of downloading images from various vendors. So here’s how I installed Docker using Homebrew and used it to run the latest version of the LSST stack:

```auto
brew install docker
brew install docker-machine
brew services start docker-machine
brew install virtualbox # Requires SystemPreferences intervention
docker-machine create default --virtualbox-cpu-count 6 --virtualbox-memory 8192

# Create "docker" group and put me in it
sudo dseditgroup -o create docker
sudo dseditgroup -o edit -a price -t user docker

# Run this to set environment before running docker
eval $(docker-machine env default)

```

Note:

- The `brew install virtualbox` command requires intervention in the “System Preferences” --\> “Security & Privacy”: you need to give permission for the installation.
- The `eval $(docker-machine env default)` line needs to be run before you use `docker run`; you may want to put it in your `~/.bashrc`.

Once Docker’s installed and set up, you can follow [the instructions for using the LSST stack images](https://pipelines.lsst.io/install/docker.html), e.g.:

```auto
docker run -ti -v ~/LSST:/home/lsst/LSST lsstsqre/centos:7-stack-lsst_distrib-w_2018_10

```

---

<div class="post-metadata">

**Author:** ![ktl](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/ktl/32/1373_2.png) [@ktl](https://www.rubin.community/u/ktl)\
**Post date:** [March 13, 2018, 5:23pm UTC](https://www.rubin.community/t/docker-for-macos-with-homebrew/2759/2 "2018-03-13T17:23:03Z")

</div>

An alternative that does require downloading an image from the vendor but does not require `brew` is to use Docker Community Edition, a single-DMG app install of docker, docker-machine, a menubar widget, etc.

[https://download.docker.com/mac/stable/Docker.dmg](https://download.docker.com/mac/stable/Docker.dmg)

---

<div class="post-metadata">

**Author:** ![mwv](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mwv](https://www.rubin.community/u/mwv)\
**Post date:** [March 14, 2018, 1:51pm UTC](https://www.rubin.community/t/docker-for-macos-with-homebrew/2759/3 "2018-03-14T13:51:48Z")

</div>

@price Thanks for posting the clear instructions for going the `homebrew` route instead of the Docker application DMG image route. Nice to have documentation of different options.

---

<div class="post-metadata">

**Author:** ![price](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/price/32/488_2.png) [@price](https://www.rubin.community/u/price)\
**Post date:** [March 26, 2018, 6:59pm UTC](https://www.rubin.community/t/docker-for-macos-with-homebrew/2759/4 "2018-03-26T18:59:08Z")

</div>

I’ve put the following in my `~/.bashrc` and found them helpful:

```auto
lsst_latest_weekly () {
    date +'w_%Y_%U'
}

eval "$(docker-machine env default)"

lsstDocker () {
    docker run -ti -v ~/docker:/home/lsst -v ~/LSST:/home/lsst/LSST lsstsqre/centos:7-stack-lsst_distrib-$(lsst_latest_weekly)
}

```

The result is that when I run `lsstDocker`, I get the latest weekly LSST-DM Docker, with a persistent home dir and my laptop’s LSST product repos.

---

<div class="post-metadata">

**Author:** ![price](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/price/32/488_2.png) [@price](https://www.rubin.community/u/price)\
**Post date:** [April 11, 2018, 9:16pm UTC](https://www.rubin.community/t/docker-for-macos-with-homebrew/2759/5 "2018-04-11T21:16:29Z")

</div>

Craig Loomis tells me that there’s no need to use a VirtualBox on OSX, but there’s [an alternate method](https://docs.docker.com/docker-for-mac/docker-toolbox/).

Without having installed `docker`, `docker-machine` or `virtualbox` (if you did install them, then `brew uninstall` them), you can do:

```auto
brew cask install docker

```

and it will install “Docker for Mac” in your Applications. Start that up, and then you can use Docker without the constraints of a Virtualbox. (And you can still manage it through `brew`.)

---

<div class="post-metadata">

**Author:** ![price](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/price/32/488_2.png) [@price](https://www.rubin.community/u/price)\
**Post date:** [April 24, 2018, 6:06pm UTC](https://www.rubin.community/t/docker-for-macos-with-homebrew/2759/6 "2018-04-24T18:06:54Z")

</div>

To get x11 (e.g., for `ds9`) working, found [this useful page](https://medium.com/@mreichelt/how-to-show-x11-windows-within-docker-on-mac-50759f4b65cb). A summary:

- XQuartz -\> Preferences -\> Security -\> enable “Allow connections from network clients”
- Quit XQuartz and restart
- In a terminal, run: `xhost + localhost`
- Add to your `docker run` command-line `-e DISPLAY=docker.for.mac.localhost:0`.

To use ds9, you’ll also have to download the CentOS 7 binary (put it in a mapped volume), and you’ll need to install the `libXft` package: `docker exec -ti --user=root <CONTAINER_HASH> yum install libXft -y`.
