Skip to content

Commit 25837b9

Browse files
mnmkngclaudeTC-MO
authored
docs(docker): add image tag naming convention and version pinning gui… (#2185)
See https://apify.slack.com/archives/CQ96RHG2U/p1768757339018769 - Added section explaining Docker image tag naming convention (e.g., `22-1.52.0` for Node.js 22 with Playwright 1.52.0) - Added direct links to Docker Hub tags pages for discovering available versions - Added guidance on pinning Playwright/Puppeteer versions for reproducible builds - Clarified that using `*` as version is a legacy approach, with pinning now preferred <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Updates `docker.md` with guidance to improve reproducibility and clarity around base images. > > - **Image tag naming convention** for Node.js and Python images, including `{runtime-version}-{library-version}` tags with examples > - **Finding available tags** via Docker Hub links and a curl/jq snippet > - **Version pinning recommendations**: pin Node/Python and Playwright/Puppeteer/Selenium versions; Dockerfile and `package.json` examples provided > - *Warning* on mismatched versions triggering extra downloads and incompatibilities; notes that using `*` is legacy and pinning is preferred > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 11df06f. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Michał Olender <92638966+TC-MO@users.noreply.github.com>
1 parent 2d88d90 commit 25837b9

1 file changed

Lines changed: 95 additions & 0 deletions

File tree

  • sources/platform/actors/development/actor_definition

sources/platform/actors/development/actor_definition/docker.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,101 @@ These images come with Python (version `3.9`, `3.10`, `3.11`, `3.12`, or `3.13`)
4949
| [`actor-python-playwright`](https://hub.docker.com/r/apify/actor-python-playwright) | Debian image with [`playwright`](https://github.com/microsoft/playwright) and all its browsers. |
5050
| [`actor-python-selenium`](https://hub.docker.com/r/apify/actor-python-selenium) | Debian image with [`selenium`](https://github.com/seleniumhq/selenium), Google Chrome, and [ChromeDriver](https://developer.chrome.com/docs/chromedriver/). |
5151

52+
## Image tag naming convention
53+
54+
Docker image tags follow a consistent naming pattern that allows you to pin specific versions:
55+
56+
### Node.js images
57+
58+
For Node.js images, the tag format is:
59+
60+
- `{node-version}` - A Node.js version only (e.g., `20`, `22`, `24`)
61+
- `{node-version}-{library-version}` - A Node.js version with pinned Playwright/Puppeteer version (e.g., `22-1.52.0`)
62+
63+
Examples:
64+
65+
| Tag | Description |
66+
| --- | ----------- |
67+
| `20` | Node.js 20 with the Playwright/Puppeteer version that was latest when the image was built |
68+
| `22` | Node.js 22 with the Playwright/Puppeteer version that was latest when the image was built |
69+
| `22-1.52.0` | Node.js 22 with Playwright/Puppeteer version 1.52.0 pinned |
70+
| `latest` | Latest LTS Node.js version |
71+
72+
### Python images
73+
74+
For Python images, the tag format is:
75+
76+
- `{python-version}` - A Python version only (e.g., `3.11`, `3.12`, `3.13`)
77+
- `{python-version}-{library-version}` - A Python version with pinned Playwright/Selenium version
78+
79+
### Available tags
80+
81+
To see all available tags for an image, visit Docker Hub:
82+
83+
- [View actor-node-playwright-chrome tags](https://hub.docker.com/r/apify/actor-node-playwright-chrome/tags)
84+
- [View actor-node-playwright tags](https://hub.docker.com/r/apify/actor-node-playwright/tags)
85+
- [View actor-node-puppeteer-chrome tags](https://hub.docker.com/r/apify/actor-node-puppeteer-chrome/tags)
86+
- [View actor-python-playwright tags](https://hub.docker.com/r/apify/actor-python-playwright/tags)
87+
88+
You can also query available tags programmatically:
89+
90+
```bash
91+
curl -s "https://registry.hub.docker.com/v2/repositories/apify/actor-node-playwright-chrome/tags?page_size=50" | jq '.results[].name'
92+
```
93+
94+
## Version pinning for reproducible builds
95+
96+
For production Actors, pin both the Node.js/Python version and the browser automation library version in your Dockerfile. This ensures reproducible builds and prevents unexpected behavior when new versions are released.
97+
98+
### Recommended approach
99+
100+
In your `Dockerfile`, use a fully pinned tag:
101+
102+
```dockerfile
103+
# Pin both Node.js 22 and Playwright 1.52.0
104+
FROM apify/actor-node-playwright-chrome:22-1.52.0
105+
```
106+
107+
In your `package.json`, match the Playwright/Puppeteer version to your Docker image tag:
108+
109+
```json
110+
{
111+
"dependencies": {
112+
"apify": "^3.5.0",
113+
"@crawlee/playwright": "^3.15.0",
114+
"playwright": "1.52.0"
115+
}
116+
}
117+
```
118+
119+
:::warning Why version matching matters
120+
121+
When the Playwright/Puppeteer version in your `package.json` differs from what's pre-installed in the Docker image, npm will download and install the version specified in `package.json`. This can lead to:
122+
123+
- Slower builds due to downloading browser binaries
124+
- Potential version incompatibilities
125+
- Inconsistent behavior between local development and production
126+
127+
:::
128+
129+
### Using `*` as version (alternative approach)
130+
131+
You may encounter older documentation or templates using `*` as the Playwright/Puppeteer version:
132+
133+
```json
134+
{
135+
"dependencies": {
136+
"playwright": "*"
137+
}
138+
}
139+
```
140+
141+
The asterisk (`*`) tells npm to use whatever version is already installed, which prevents re-downloading the library. While this approach still works, **pinning specific versions is now preferred** because:
142+
143+
1. Reproducibility - Your builds will behave the same way regardless of when you build them
144+
1. Predictability - You know exactly which version you're running
145+
1. Debugging - Version-specific issues are easier to track down
146+
52147
## Custom Dockerfile
53148

54149
Apify uses Docker to build and run Actors. If you create an Actor from a template, it already contains an optimized `Dockerfile` for the given use case.

0 commit comments

Comments
 (0)