Skip to content

Commit 3a4641c

Browse files
Copilotamitsaha
andcommitted
docs: add per-platform Docker usage section (Linux, macOS, Windows)
Co-authored-by: amitsaha <512598+amitsaha@users.noreply.github.com> Agent-Logs-Url: https://github.com/amitsaha/gitbackup/sessions/d9a5d8e9-a12f-49d2-969c-9738801e5eea
1 parent b8af4cb commit 3a4641c

1 file changed

Lines changed: 57 additions & 11 deletions

File tree

README.md

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,56 +67,102 @@ docker pull ghcr.io/amitsaha/gitbackup:<version>
6767

6868
Replace `<version>` with the desired release tag (e.g. `0.9.1`).
6969

70-
#### Running with a volume mount
70+
The container runs as a non-root user (`nonroot`, UID `65532`). HTTPS cloning (`-use-https-clone`) is recommended inside containers because it requires no SSH key management.
7171

72-
The container runs as a non-root user (`nonroot`, UID `65532`). You must ensure the backup directory on the host is writable by that UID before mounting it:
72+
#### Linux
73+
74+
On Linux, Docker runs natively so container UIDs map directly to host UIDs. Before mounting a backup directory, grant write access to UID `65532`:
7375

7476
```bash
7577
mkdir -p /data/gitbackup
7678
chown 65532:65532 /data/gitbackup
7779
```
7880

79-
Then run the container, mounting the directory as the backup target:
81+
Run with HTTPS cloning (recommended):
82+
83+
```bash
84+
docker run --rm \
85+
-e GITHUB_TOKEN=<your-token> \
86+
-v /data/gitbackup:/backup \
87+
ghcr.io/amitsaha/gitbackup:<version> \
88+
-service github -backupdir /backup -use-https-clone
89+
```
90+
91+
If you need SSH cloning, make a copy of your private key readable by UID `65532` and mount it:
8092

8193
```bash
94+
cp $HOME/.ssh/id_rsa /tmp/gitbackup_id_rsa
95+
chown 65532 /tmp/gitbackup_id_rsa
96+
chmod 600 /tmp/gitbackup_id_rsa
97+
8298
docker run --rm \
8399
-e GITHUB_TOKEN=<your-token> \
84100
-v /data/gitbackup:/backup \
101+
-v /tmp/gitbackup_id_rsa:/home/nonroot/.ssh/id_rsa:ro \
102+
-v $HOME/.ssh/known_hosts:/home/nonroot/.ssh/known_hosts:ro \
85103
ghcr.io/amitsaha/gitbackup:<version> \
86104
-service github -backupdir /backup
87105
```
88106

89-
#### HTTPS cloning (recommended in containers)
107+
#### macOS
90108

91-
By default `gitbackup` clones repositories over SSH, which requires access to an SSH key and a populated `known_hosts` file inside the container. The simpler alternative is to use HTTPS cloning via the `-use-https-clone` flag — no SSH keys are required:
109+
Docker Desktop for Mac runs containers inside a Linux VM and translates volume mounts through its filesystem layer (VirtioFS). Because of this translation, the container UID (`65532`) is mapped automatically — you do **not** need to `chown` the host directory. Paths use the same Unix syntax as Linux.
92110

93111
```bash
112+
mkdir -p $HOME/gitbackup
113+
94114
docker run --rm \
95115
-e GITHUB_TOKEN=<your-token> \
96-
-v /data/gitbackup:/backup \
116+
-v $HOME/gitbackup:/backup \
97117
ghcr.io/amitsaha/gitbackup:<version> \
98118
-service github -backupdir /backup -use-https-clone
99119
```
100120

101-
#### SSH cloning
102-
103-
If you need SSH cloning, mount your private key and `known_hosts` into the container user's home directory. Because the container user is `nonroot` (UID `65532`), ensure the key file is readable by that UID:
121+
SSH cloning on macOS requires the same key-ownership step as Linux. Although VirtioFS handles write permissions for the backup directory automatically, `git` performs a strict ownership check on the SSH private key inside the container — the key file must be owned by the user running inside the container (UID `65532`). Host UIDs on macOS are unrelated to container UIDs, so the ownership must be set explicitly on a copy of the key:
104122

105123
```bash
106-
# Make a copy of the key owned by UID 65532
107124
cp $HOME/.ssh/id_rsa /tmp/gitbackup_id_rsa
108125
chown 65532 /tmp/gitbackup_id_rsa
109126
chmod 600 /tmp/gitbackup_id_rsa
110127

111128
docker run --rm \
112129
-e GITHUB_TOKEN=<your-token> \
113-
-v /data/gitbackup:/backup \
130+
-v $HOME/gitbackup:/backup \
114131
-v /tmp/gitbackup_id_rsa:/home/nonroot/.ssh/id_rsa:ro \
115132
-v $HOME/.ssh/known_hosts:/home/nonroot/.ssh/known_hosts:ro \
116133
ghcr.io/amitsaha/gitbackup:<version> \
117134
-service github -backupdir /backup
118135
```
119136

137+
#### Windows
138+
139+
Docker Desktop for Windows (WSL2 backend recommended) translates volume mounts through the WSL2 VM, so no `chown` is needed on the host directory. Use PowerShell syntax for environment variables and paths:
140+
141+
```powershell
142+
# PowerShell
143+
New-Item -ItemType Directory -Force "$env:USERPROFILE\gitbackup"
144+
145+
docker run --rm `
146+
-e GITHUB_TOKEN=$env:GITHUB_TOKEN `
147+
-v "${env:USERPROFILE}\gitbackup:/backup" `
148+
ghcr.io/amitsaha/gitbackup:<version> `
149+
-service github -backupdir /backup -use-https-clone
150+
```
151+
152+
If you prefer Command Prompt:
153+
154+
```cmd
155+
mkdir %USERPROFILE%\gitbackup
156+
157+
docker run --rm ^
158+
-e GITHUB_TOKEN=%GITHUB_TOKEN% ^
159+
-v "%USERPROFILE%\gitbackup:/backup" ^
160+
ghcr.io/amitsaha/gitbackup:<version> ^
161+
-service github -backupdir /backup -use-https-clone
162+
```
163+
164+
SSH cloning on Windows requires your SSH key to be accessible from WSL2 or Docker Desktop. The recommended approach is to store your key under WSL2 and mount it using a WSL path, or use HTTPS cloning to avoid SSH key management altogether.
165+
120166
## Using `gitbackup`
121167

122168
``gitbackup`` requires a [GitHub API access token](https://github.com/blog/1509-personal-api-tokens) for

0 commit comments

Comments
 (0)