You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sources/platform/actors/development/actor_definition/docker.md
+111-5Lines changed: 111 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ All Apify Docker images are pre-cached on Apify servers to speed up Actor builds
26
26
27
27
### Node.js base images
28
28
29
-
These images come with Node.js (versions `16`, `18`, `20`, or `22`) the [Apify SDK for JavaScript](/sdk/js), and [Crawlee](https://crawlee.dev/) preinstalled. The `latest` tag corresponds to the latest LTS version of Node.js.
29
+
These images come with Node.js (versions `20`, `22`, or `24`) the [Apify SDK for JavaScript](/sdk/js), and [Crawlee](https://crawlee.dev/) preinstalled. The `latest` tag corresponds to the latest LTS version of Node.js.
30
30
31
31
| Image | Description |
32
32
| ----- | ----------- |
@@ -41,7 +41,7 @@ See the [Docker image guide](/sdk/js/docs/guides/docker-images) for more details
41
41
42
42
### Python base images
43
43
44
-
These images come with Python (version `3.8`, `3.9`, `3.10`, `3.11`, or `3.12`) and the [Apify SDK for Python](/sdk/python) preinstalled. The `latest` tag corresponds to the latest Python 3 version supported by the Apify SDK.
44
+
These images come with Python (version `3.9`, `3.10`, `3.11`, `3.12`, or `3.13`) and the [Apify SDK for Python](/sdk/python) preinstalled. The `latest` tag corresponds to the latest Python 3 version supported by the Apify SDK.
45
45
46
46
| Image | Description |
47
47
| ----- | ----------- |
@@ -61,9 +61,9 @@ To use a custom `Dockerfile`, you can either:
61
61
If no `Dockerfile` is provided, the system uses the following default:
62
62
63
63
```dockerfile
64
-
FROM apify/actor-node:20
64
+
FROM apify/actor-node:24
65
65
66
-
COPY package*.json ./
66
+
COPY--chown=myuser:myuser package*.json ./
67
67
68
68
RUN npm --quiet set progress=false \
69
69
&& npm install --only=prod --no-optional \
@@ -74,7 +74,7 @@ RUN npm --quiet set progress=false \
74
74
&& echo "NPM version:" \
75
75
&& npm --version
76
76
77
-
COPY . ./
77
+
COPY--chown=myuser:myuser . ./
78
78
```
79
79
80
80
For more information about `Dockerfile` syntax and commands, see the [Dockerfile reference](https://docs.docker.com/reference/dockerfile/).
@@ -112,3 +112,109 @@ This means the system expects the source code to be in `main.js` by default. If
112
112
You can check out various optimization tips for Dockerfile in our [Performance](../performance.md) documentation.
113
113
114
114
:::
115
+
116
+
## Updating older Dockerfiles
117
+
118
+
All Apify base Docker images now use a non-root user to enhance security. This change requires updates to existing Actor `Dockerfile`s that use the `apify/actor-node`, `apify/actor-python`, `apify/actor-python-playwright`, or `apify/actor-python-selenium` images. This section provides guidance on resolving common issues that may arise during this migration.
119
+
120
+
If you encounter an issue that is not listed here, or need more guidance on how to update your Dockerfile, please [open an issue in the apify-actor-docker GitHub repository](https://github.com/apify/apify-actor-docker/issues/new).
121
+
122
+
:::danger Action required
123
+
124
+
As of **August 25, 2025** the base Docker images display a deprecation warning that links you here. This warning will be removed start of **February 2026**, so you should update your Dockerfiles to ensure forward compatibility.
125
+
126
+
:::
127
+
128
+
### User and working directory
129
+
130
+
To improve security, the affected images no longer run as the `root` user. Instead, they use a dedicated non-root user, `myuser`, and a consistent working directory at `/home/myuser`. This configuration is now the standard for all Apify base Docker images.
131
+
132
+
### Common issues
133
+
134
+
#### Crawlee templates automatically installing `git` in Python images
135
+
136
+
If you've built your Actor using a [Crawlee](https://crawlee.dev/) template, you might have the following line in your `Dockerfile`:
You can safely remove this line, as the `git` package is now installed in the base image.
143
+
144
+
#### `uv` package manager fails to install dependencies
145
+
146
+
If you are using the `uv` package manager, you might have the following line in your `Dockerfile`:
147
+
148
+
```dockerfile
149
+
ENV UV_PROJECT_ENVIRONMENT="/usr/local"
150
+
```
151
+
152
+
With the move to a non-root user, this variable will cause `uv` to throw a permission error. You can safely remove this line, or, if you need it set to a custom path, adjust it to point to a location in the `/home/myuser` directory.
153
+
154
+
#### Copying files with the correct permissions
155
+
156
+
When using the `COPY` instruction to copy your files to the container, you should append the `--chown=myuser:myuser` flag to the command to ensure the `myuser` user owns the files.
157
+
158
+
Here are a few common examples:
159
+
160
+
```dockerfile
161
+
COPY --chown=myuser:myuser requirements.txt ./
162
+
163
+
COPY --chown=myuser:myuser . ./
164
+
```
165
+
166
+
:::warning
167
+
168
+
If your `Dockerfile` contains a `RUN` instruction similar to the following one, you should remove it:
169
+
170
+
```dockerfile
171
+
RUN chown -R myuser:myuser /home/myuser
172
+
```
173
+
174
+
Instead, add the `--chown` flag to the `COPY` instruction:
175
+
176
+
```dockerfile
177
+
COPY --chown=myuser:myuser . ./
178
+
```
179
+
180
+
Running `chown` across multiple files needlessly slows down the build process. Using the flag on `COPY` is much more efficient.
181
+
182
+
:::
183
+
184
+
#### An `apify` user is being added by a template
185
+
186
+
If your `Dockerfile` has instructions similar to the following, they were likely added by an older template:
187
+
188
+
```dockerfile
189
+
# Create and run as a non-root user.
190
+
RUN adduser -h /home/apify -D apify && \
191
+
chown -R apify:apify ./
192
+
USER apify
193
+
```
194
+
195
+
You should remove these lines, as the new user is now `myuser`. Don't forget to update your `COPY` instructions to use the `--chown` flag with the `myuser` user.
196
+
197
+
```dockerfile
198
+
COPY --chown=myuser:myuser . ./
199
+
```
200
+
201
+
#### Installing dependencies that require root access
202
+
203
+
The `root` user is still available in the Docker images. If you must run steps that require root access (like installing system packages with `apt` or `apk`), you can temporarily switch to the `root` user.
204
+
205
+
```dockerfile
206
+
FROM apify/actor-node:24
207
+
208
+
# Switch to root temporarily to install dependencies
209
+
USER root
210
+
211
+
RUN apt update \
212
+
&& apt install -y <dependencies here>
213
+
214
+
# Switch back to the non-root user
215
+
USER myuser
216
+
217
+
# ... your other instructions
218
+
```
219
+
220
+
If your Actor needs to run as `root` for a specific reason, you can add the `USER root` instruction after `FROM`. However, for a majority of Actors, this is not necessary.
0 commit comments