# Hacks This documentation describes how docker/OCI image pulls on a local linux box can be configured to connect to mirrors or pull through cache proxies. The audience is developers who want to have faster or more reliable pulls, and want to avoid rate limits from external registries. This part is called 'hacks' and describes some more hands-on components and investigations on the command line. ## Create an own registry mirror to test a kind mirror setting May be you don't have or need a mirror, but you would like to run all sceanrios of part 2 and thus need a local mirror. Or you would like to investigate the handshaking between mirror and cache and thus need the logs of the mirror. ```bash # the name of our mirror MIRROR_NAME=registry.docker.io.mirror.test # the mirror will be accessable by its host name in the kind network DOCKER_KIND_NETWORK=kind ``` ## The registry needs TLS ```bash # create a temporary directory mkdir registry-certs ``` ```bash # cert config cat <openssl-${MIRROR_NAME}.cnf [req] default_bits = 2048 default_keyfile = domain.key distinguished_name = req_distinguished_name x509_extensions = v3_ca req_extensions = v3_ca prompt = no [req_distinguished_name] countryName = DE stateOrProvinceName = SomeState localityName = SomeCity organizationName = MyCompany organizationalUnitName = IT commonName = ${MIRROR_NAME} [v3_ca] subjectAltName = @alt_names [alt_names] DNS.1 = ${MIRROR_NAME} EOF ``` ```bash # create self signed cert openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout registry-certs/${MIRROR_NAME}.key -out registry-certs/${MIRROR_NAME}.crt -config openssl-${MIRROR_NAME}.cnf ``` ### Now run the registry ```bash # run registry as mirror docker run -d \ --name ${MIRROR_NAME} \ --network $DOCKER_KIND_NETWORK \ -p 443:443 \ -v $(pwd)/registry-certs:/certs \ -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/${MIRROR_NAME}.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/${MIRROR_NAME}.key \ -e REGISTRY_PROXY_REMOTEURL="https://registry-1.docker.io" \ registry:2 ``` ### Next run the kind cluster ```bash # create kind cluster cat <> /etc/ssl/certs/ca-certificates.crt' docker exec -it docker_registry_proxy bash -c 'kill -SIGHUP $(cat /run/nginx.pid)' ```