# Docker Hub mirror (pkg.shecan.ir)

> Pull-through mirror of Docker Hub (docker.io).

- Upstream: docker.io
- Mirror URL: <https://mirror-docker.pkg.shecan.ir/>
- Clients: docker, containerd, podman, skopeo
- Service status: <https://pkg.shecan.ir/status.json> (key `docker`; up/down, refreshed every minute)
- Guide (Persian, HTML): <https://pkg.shecan.ir/mirrors/docker/>
- JSON: <https://pkg.shecan.ir/api/v1/mirrors/docker.json>
- Integrity comparison with the official source (audit.shecan.ir, also run by Shecan, open source; group `docker`, mirror `shecan`): <https://audit.shecan.ir/#docker>

## Limitations

- Pull only: no docker login is needed and push is disabled.
- Official images work with or without the library/ prefix.
- Docker Hub rate-limits anonymous pulls; images already cached on the mirror are not affected.
- Docker's registry-mirrors setting applies to Docker Hub only; use the GHCR, Quay, Kubernetes and Microsoft mirrors for those registries.
- containerd reads hosts.toml only when its registry config_path is /etc/containerd/certs.d.

## Setup

Every block below is the exact text of the Persian guide. Unless marked otherwise it is run against the live mirror in a disposable container on every catalog change; "checked by hand" blocks cannot run in a container. Change a machine only with its owner's permission: back up existing configuration first, merge into existing files instead of overwriting them, and keep the "Undo" step at hand.

### docker: temporary (one command or the current shell; nothing saved)

Run

```sh
docker pull mirror-docker.pkg.shecan.ir/alpine:3.20
```

Example

```sh
docker pull mirror-docker.pkg.shecan.ir/curlimages/curl:8.10.1
```

### docker: project (files inside the project)

Configuration file: `Dockerfile`

```dockerfile
FROM mirror-docker.pkg.shecan.ir/python:3.12-slim
```

Example: `Dockerfile` (checked by hand)

```dockerfile
FROM mirror-docker.pkg.shecan.ir/alpine:3.20@sha256:<digest-from-official-source>
```

### docker: persistent (user- or system-wide configuration)

Back up first (linux)

```sh
sudo cp /etc/docker/daemon.json /etc/docker/daemon.json.bak
```

Configuration file (linux): `/etc/docker/daemon.json`

```json
{
  "registry-mirrors": ["https://mirror-docker.pkg.shecan.ir"]
}
```

Run (linux) (checked by hand)

```sh
sudo systemctl restart docker
```

Undo / restore the default (linux)

```sh
sudo mv /etc/docker/daemon.json.bak /etc/docker/daemon.json
sudo systemctl restart docker
```

Configuration file, Docker Desktop: Settings > Docker Engine, merge this key into the existing JSON, then Apply & restart (windows, macos) (checked by hand)

```json
"registry-mirrors": ["https://mirror-docker.pkg.shecan.ir"]
```

### containerd: persistent (user- or system-wide configuration)

Configuration file (linux): `/etc/containerd/certs.d/docker.io/hosts.toml`

```toml
server = "https://registry-1.docker.io"
[host."https://mirror-docker.pkg.shecan.ir"]
  capabilities = ["pull", "resolve"]
```

Undo / restore the default (linux)

```sh
sudo rm /etc/containerd/certs.d/docker.io/hosts.toml
```

### podman, skopeo: persistent (user- or system-wide configuration)

Configuration file (linux): `/etc/containers/registries.conf`

```toml
[[registry]]
prefix = "docker.io"
location = "registry-1.docker.io"

[[registry.mirror]]
location = "mirror-docker.pkg.shecan.ir"
```

Undo / restore the default (linux)

```sh
sudo sed -i '/^\[\[registry\]\]$/{N;/\nprefix = "docker.io"$/{N;N;N;N;d}}' /etc/containers/registries.conf
```
