diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..95f6828 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +services: + app: +# image: registry.tbxark.cn/docker-registry-proxy:latest + build: . + network_mode: bridge + container_name: docker-registry-proxy + pull_policy: always + ports: + - "8989:8989" + restart: always + command: ["--address", "0.0.0.0:8989", "--registry", "mirror.ccs.tencentyun.com"] \ No newline at end of file diff --git a/main.go b/main.go index d00c09f..de1071d 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,7 @@ func main() { proxy := NewRegistryProxy(registryHost) http.HandleFunc("/", proxy.handler) + log.Printf("server start: %s", serveAddress) log.Fatal(http.ListenAndServe(serveAddress, nil)) } @@ -49,6 +50,7 @@ func NewRegistryProxy(host string) *RegistryProxy { func (p *RegistryProxy) handler(w http.ResponseWriter, r *http.Request) { path := r.URL.Path originalHost := r.Host + log.Printf("[%s] %s", r.Method, path) if strings.HasPrefix(path, "/v2/") { registryURL := fmt.Sprintf("https://%s%s", p.host, path) req, err := http.NewRequest(r.Method, registryURL, r.Body)