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
Fix exit on error during migrations, CI updates, and improve notices and messages (#490)
* Force do not exit on error for the try loop on migrations. Fixes#489
* Update notice for custom commands
* Removed Alpine from 7.4.33 because Alpine 3.16 reached EOL (#426 (comment))
* Removed Alpine from PHP 8.0 because Alpine 3.16 reached EOL (#426 (comment))
* Added PHP version and image version to container info start up
* Switch to GitHub runners on Ubuntu 24.04
* Set GHA cache
* Re-added alpine for 7.4 and 8.0 (#426 (comment))
* Converted to buildx and added platform support
* Adjusted PRs to run automatically
* Deprecated and removed linux/arm/v7
* Sign into docker registry only if we're pushing the image
* Added docs to clarify why we don't use subshells (#481 (comment))
* Fixed link
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Supercharge your PHP experience with Docker images that are based off the official PHP images but are optimized to be run in production environments for Laravel and WordPress and more
Copy file name to clipboardExpand all lines: docs/content/docs/5.customizing-the-image/3.adding-your-own-start-up-scripts.md
+16-1Lines changed: 16 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@ Your script should:
18
18
- Located in the `/etc/entrypoint.d` directory
19
19
- Have the file extension ending in `.sh`
20
20
::
21
+
21
22
We recommend writing your script in `/bin/sh` for the best compatibility between Alpine and Debian. If you choose to use `/bin/bash`, your script will only be able to run on Debian-based images.
22
23
23
24
## Choose your execution order
@@ -27,6 +28,15 @@ Since [we provide default entrypoint scripts](/docs/getting-started/default-conf
27
28
If you want to disable our entrypoint scripts, you can set `DISABLE_DEFAULT_CONFIG` to `true` in your environment variables.
28
29
::
29
30
31
+
## Long running services
32
+
::note
33
+
Don't use entrypoint scripts for long-running services. You want your services to be monitored and restarted if they crash.
34
+
::
35
+
36
+
Anything in the `/etc/entrypoint.d` directory are scripts that are intended to run quickly and then move on. If you run a service as an entrypoint script, that service may crash and not be restarted.
37
+
38
+
Instead, learn about [using S6 overlay](/docs/guide/using-s6-overlay) so your services can be properly initialized and monitored. See the [S6 Overylay project](https://github.com/just-containers/s6-overlay) for more details on how to write your own S6 service.
39
+
30
40
## Example: Create a custom entrypoint script
31
41
In this example, let's create a `99-my-script.sh` so it executes after all the other default scripts.
32
42
@@ -95,6 +105,11 @@ services:
95
105
96
106
In the above file, we're building our image using the `Dockerfile` in the current directory. We're also mounting our current directory to `/var/www/html` in the container.
97
107
108
+
## Don't use `exit 0` in your script
109
+
If you use `exit 0` in your script, it will stop the execution of the rest of the entrypoint scripts. We recommend using `return 0` instead. [See this discussion](https://github.com/serversideup/docker-php/issues/481#issuecomment-2463082306) for more details on why.
110
+
111
+
Long story short, we don't use subshells to execute your scripts, so `exit 0` will not work as expected. We do this because we want to ensure your script has access to the environment variables that are set in the entrypoint scripts.
112
+
98
113
## Running our example
99
114
When we run `docker compose up`, we should see the following output:
0 commit comments