SQRD

Docker

Run Mac OS X in a Docker container.

Setup on Ubuntu

Install Docker on Ubuntu 22.04

Setup a registry

Prepare passwords

mkdir auth
docker run --entrypoint htpasswd httpd:2 -Bbn username <password> > auth/htpasswd

Launch the registry

docker run -d \
  -p 5000:5000 \
  --restart=always \
  --name registry \
  -v /var/lib/registry:/var/lib/registry \
  -v "$(pwd)"/auth:/auth \
  -e "REGISTRY_AUTH=htpasswd" \
  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry" \
  -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
  registry:2

Commands

# stop the registry
docker container stop registry

# tag an image to the registry
docker tag shaper registry.domain.com/shaper

# push/pull image to the registry
docker push registry.domain.com/shaper
docker pull registry.domain.com/shaper

Setup an nginx proxy (src)

server {
  server_name registry.domain.com;

  proxy_send_timeout   120;
  proxy_buffering      off;
  tcp_nodelay          on;
  access_log           off;
  client_max_body_size 0;
  chunked_transfer_encoding on;

  location /v2/ {
    if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
      return 404;
    }
    proxy_pass                          http://127.0.0.1:5000;
    proxy_set_header Host               $http_host;
    proxy_set_header X-Real-IP          $remote_addr; # pass on real client's IP
    proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-Host   $host:$server_port;
    proxy_set_header X-Original-URI     $request_uri;
    proxy_set_header Docker-Distribution-Api-Version registry/2.0;
    proxy_read_timeout 900;
  }

  listen 443 ssl;
  # ssl settingsā€¦
}
: