Self-hosted Renovate with Docker Compose
In my previous posts, Let Renovate keep your Docker images up to date and Renovate beyond Docker, I used the hosted Mend Renovate app. It works well, but I have now moved to running Renovate myself.
Self-hosting is something I like to do for the following reasons
- I decide when and how often Renovate runs
- it works the same way for GitLab and GitHub
- The Access Tokens stay on your machine
- I don't depend on external services
The whole setup is a Docker Compose file, a config file and a small script. That is it.
Prerequisites
- Docker and Docker Compose
- A access token for each platform you want Renovate to work on
- A repository that you can test with
If you don't have a repository to test on, create a small one, like I did, with a Dockerfile and a docker-compose.yml, each with a pinned image.
Create a access token
Renovate needs a token to read your repositories and create pull requests.
- GitLab: create a personal access token (or a project access token) with the scopes
apiandwrite_repository - GitHub: create a personal access token with the
reposcope. If you want Renovate to update your workflow files too, it also needsworkflow
Keep the token secret. Never commit it to a repository, and add .env to your .gitignore.
The files
I keep everything in one folder.
renovate/
├── .env
├── .gitignore
├── config.js
├── docker-compose.yml
└── entrypoint.sh
In my examples I use gitlab.com as GitLab Host.
.env
RENOVATE_TOKEN=<your-token>
This is the only place where the token lives. Docker Compose reads the file automatically.
docker-compose.yml
services:
renovate:
image: renovate/renovate:<version>
container_name: renovate
restart: unless-stopped
environment:
- RENOVATE_TOKEN=${RENOVATE_TOKEN}
# Only needed for self-hosted GitLab or GitHub Enterprise
# - RENOVATE_ENDPOINT=https://gitlab.example.com/api/v4
volumes:
- ./config.js:/usr/src/app/config.js:ro
- ./entrypoint.sh:/entrypoint.sh:ro
entrypoint: ["/bin/bash", "/entrypoint.sh"]
There are a few things to notice here
- The config file is mounted to
/usr/src/app/config.js. That is where Renovate looks for it, so no extra flags are needed - I replace the default entrypoint with my own script, to run Renovate on a schedule
restart: unless-stoppedmakes sure the container comes back after a reboot- I pin the image to a version instead of
latest. This is the same advice as in my first Renovate post, and Renovate can update its own image for you
If you use gitlab.com, you can leave out RENOVATE_ENDPOINT. It is only needed for self-hosted instances.
config.js
module.exports = {
// Can be 'github', 'gitlab', 'gitea', 'bitbucket', etc.
platform: 'gitlab',
// Scan all repositories that the token can access
autodiscover: false,
// Limit Renovate to specific repositories instead
repositories: ['tomasnorre/renovate-poc-gitlab'],
gitAuthor: 'Renovate Bot <mail@7th-green.com>',
// Use the recommended presets
extends: ['config:recommended'],
};
I have autodiscover turned off, and list the repositories I want Renovate to look at. It is the safer choice while you are testing, as Renovate can't surprise you with pull requests in repositories you forgot about.
When you are comfortable with it, you can turn autodiscover on, and Renovate will find all repositories the token has access to.
The extends line is the same preset that I used in the hosted setup, so the behaviour is the same, including the Dependency Dashboard.
entrypoint.sh
Renovate runs once and exits. To have it run regularly, I use a small loop.
#!/usr/bin/env bash
# Interval in seconds (3600 seconds = 1 hour)
INTERVAL=3600
while true; do
echo "[$(date)] Starting scheduled Renovate run..."
renovate
echo "[$(date)] Run complete. Sleeping for $((INTERVAL / 60)) minutes..."
sleep $INTERVAL
done
It is not fancy, but it works. You could also use cron, a systemd timer or a scheduler like Ofelia, but I like that this keeps everything in one place, and that I can see the timestamps in the container logs.
Start it
docker compose up -d
And watch what it does
docker compose logs -f renovate
If something doesn't work as expected, set LOG_LEVEL=debug in the environment section and restart the container. The debug log is long, but it tells you why Renovate did, or didn't, do something.
Onboarding
When you self-host, there is no Mend setting for silent or interactive mode, like I wrote about in my first post. Renovate creates an onboarding pull request in each repository that doesn't have a config yet, and you merge it to get started.
If you already have a renovate.json, Renovate skips this and goes straight to the update pull requests.
Adding GitHub
A Renovate run works with one platform at a time. To have it work on both GitLab and GitHub, I run a second container with its own config and token.
The second config is almost the same, only the platform and the repositories are different.
module.exports = {
platform: 'github',
autodiscover: false,
repositories: ['tomasnorre/renovate-poc'],
gitAuthor: 'Renovate Bot <tomasnorre@users.noreply.github.com>',
extends: ['config:recommended'],
};
I rename the config files to config.gitlab.js and config.github.js, and add a second service to the compose file. The token for each platform gets its own variable in .env.
GITLAB_RENOVATE_TOKEN=<your-gitlab-token>
GITHUB_RENOVATE_TOKEN=<your-github-token>
services:
renovate-gitlab:
image: renovate/renovate:<version>
restart: unless-stopped
environment:
- RENOVATE_TOKEN=${GITLAB_RENOVATE_TOKEN}
- GITHUB_COM_TOKEN=${GITHUB_RENOVATE_TOKEN}
volumes:
- ./config.gitlab.js:/usr/src/app/config.js:ro
- ./entrypoint.sh:/entrypoint.sh:ro
entrypoint: ["/bin/bash", "/entrypoint.sh"]
renovate-github:
image: renovate/renovate:<version>
restart: unless-stopped
environment:
- RENOVATE_TOKEN=${GITHUB_RENOVATE_TOKEN}
volumes:
- ./config.github.js:/usr/src/app/config.js:ro
- ./entrypoint.sh:/entrypoint.sh:ro
entrypoint: ["/bin/bash", "/entrypoint.sh"]
The GITHUB_COM_TOKEN on the GitLab service is optional, but I recommend it. When Renovate runs on another platform, it fetches release notes and changelogs from GitHub, and without a token it can hit the rate limit quickly.
A small warning
The token can create branches and pull requests in your repositories, so treat it like a password. Give it access only to the repositories that you need, and rotate it from time to time.
Conclusion
Self-hosting Renovate is less work than I expected. A compose file, a config and a loop, and I have the same pull requests as with the hosted app, for both GitLab and GitHub.
Have fun with your own Renovate.
The Expert Behind 7th Green
Hi, I'm Tomas Norre Mikkelsen. I’m the owner at 7th Green, and I bring over 20 years of hands-on experience to every project.
When you work with me, you get a developer who understands PHP and TYPO3 deeply—from core development and extension architecture to frontend/backend integrations and DevOps workflows.
This background allows me to bridge the gap between a developer’s need for clarity and a business's need for reliability. I provide full lifecycle support and create automation setups that are efficient, transparent, and easy to maintain, ensuring you never end up with a black box that only works once.