2016-09-29 19:21:06 +00:00
---
2016-10-17 22:00:00 +00:00
description: Explains how to run a registry on macOS
2016-11-10 19:54:25 +00:00
keywords: registry, on-prem, images, tags, repository, distribution, macOS, recipe, advanced
2017-08-22 23:43:21 +00:00
title: macOS setup guide
2016-09-29 19:21:06 +00:00
---
2016-09-28 21:46:28 +00:00
2021-04-22 10:33:35 +00:00
## Use-case
2016-10-17 22:00:00 +00:00
This is useful if you intend to run a registry server natively on macOS.
2021-04-22 10:33:35 +00:00
### Alternatives
2016-10-17 22:00:00 +00:00
You can start a VM on macOS, and deploy your registry normally as a container using Docker inside that VM.
2021-04-22 10:33:35 +00:00
### Solution
2016-10-17 22:00:00 +00:00
Using the method described here, you install and compile your own from the git repository and run it as an macOS agent.
2021-04-22 10:33:35 +00:00
### Gotchas
2016-10-17 22:00:00 +00:00
Production services operation on macOS is out of scope of this document. Be sure you understand well these aspects before considering going to production with this.
2021-04-22 10:33:35 +00:00
## Setup golang on your machine
If you know, safely skip to the next section.
If you don't, the TLDR is:
2023-10-12 07:32:37 +00:00
```console
$ bash < < (curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
$ source ~/.gvm/scripts/gvm
$ gvm install go1.4.2
$ gvm use go1.4.2
```
2021-04-22 10:33:35 +00:00
If you want to understand, you should read [How to Write Go Code ](https://golang.org/doc/code.html ).
2022-01-19 09:31:42 +00:00
## Checkout the source tree
2021-04-22 10:33:35 +00:00
2023-10-12 07:32:37 +00:00
```console
$ mkdir -p $GOPATH/src/github.com/distribution
$ git clone https://github.com/distribution/distribution.git $GOPATH/src/github.com/distribution/distribution
$ cd $GOPATH/src/github.com/distribution/distribution
```
2021-04-22 10:33:35 +00:00
## Build the binary
2023-10-12 07:32:37 +00:00
```console
$ GOPATH=$(PWD)/Godeps/_workspace:$GOPATH make binaries
$ sudo mkdir -p /usr/local/libexec
$ sudo cp bin/registry /usr/local/libexec/registry
```
2021-04-22 10:33:35 +00:00
## Setup
Copy the registry configuration file in place:
2023-10-12 07:32:37 +00:00
```console
$ mkdir /Users/Shared/Registry
$ cp docs/osx/config.yml /Users/Shared/Registry/config.yml
```
2021-04-22 10:33:35 +00:00
2022-01-19 09:31:42 +00:00
## Run the registry under launchd
2021-04-22 10:33:35 +00:00
2022-01-19 09:31:42 +00:00
Copy the registry plist into place:
2021-04-22 10:33:35 +00:00
2023-10-12 07:32:37 +00:00
```console
$ plutil -lint docs/recipes/osx/com.docker.registry.plist
$ cp docs/recipes/osx/com.docker.registry.plist ~/Library/LaunchAgents/
$ chmod 644 ~/Library/LaunchAgents/com.docker.registry.plist
```
2021-04-22 10:33:35 +00:00
2022-01-19 09:31:42 +00:00
Start the registry:
2021-04-22 10:33:35 +00:00
2023-10-12 07:32:37 +00:00
```console
$ launchctl load ~/Library/LaunchAgents/com.docker.registry.plist
```
2021-04-22 10:33:35 +00:00
2022-01-19 09:31:42 +00:00
### Restart the registry service
2021-04-22 10:33:35 +00:00
2023-10-12 07:32:37 +00:00
```console
$ launchctl stop com.docker.registry
$ launchctl start com.docker.registry
```
2021-04-22 10:33:35 +00:00
2022-01-19 09:31:42 +00:00
### Unload the registry service
2021-04-22 10:33:35 +00:00
2023-10-12 07:32:37 +00:00
```console
$ launchctl unload ~/Library/LaunchAgents/com.docker.registry.plist
```