Skip to content

Commit c60e17b

Browse files
committed
remove new page & merge it with existing docker.md
fix prose for clarity & conciseness change admonition title remove time anchor change headings
1 parent ac630c2 commit c60e17b

File tree

2 files changed

+106
-128
lines changed

2 files changed

+106
-128
lines changed

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

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,109 @@ This means the system expects the source code to be in `main.js` by default. If
112112
You can check out various optimization tips for Dockerfile in our [Performance](../performance.md) documentation.
113113

114114
:::
115+
116+
## Updating older Dockerfiles
117+
118+
Certain 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+
:::danger Action required
121+
122+
The base Docker images display a deprecation warning. This warning will be removed in future versions, so you should update your Dockerfiles to ensure forward compatibility.
123+
124+
For further assistance, [open an issue in the apify-actor-docker GitHub repository](https://github.com/apify/apify-actor-docker/issues/new).
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`:
137+
138+
```dockerfile
139+
RUN apt update && apt install -yq git && rm -rf /var/lib/apt/lists/*
140+
```
141+
142+
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 adjust it to point to 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.

sources/platform/actors/development/docker_user_updates.md

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)