Skip to content

Commit b1671d2

Browse files
ericsciplesalilsubsunbrye
authored
Add entrypoint and command docs for service containers (#60567)
Co-authored-by: Salil <salilsub@users.noreply.github.com> Co-authored-by: Sunbrye Ly <56200261+sunbrye@users.noreply.github.com>
1 parent 1000771 commit b1671d2

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

content/actions/reference/workflows-and-actions/workflow-syntax.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,45 @@ Additional Docker container resource options. For a list of options, see [`docke
11821182
> [!WARNING]
11831183
> The `--network` option is not supported.
11841184

1185+
{% ifversion fpt or ghec %}
1186+
1187+
## `jobs.<job_id>.services.<service_id>.command`
1188+
1189+
Overrides the Docker image's default command (`CMD`). The value is passed as arguments after the image name in the `docker create` command. If you also specify `entrypoint`, `command` provides the arguments to that entrypoint.
1190+
1191+
### Example of `jobs.<job_id>.services.<service_id>.command`
1192+
1193+
```yaml
1194+
services:
1195+
mysql:
1196+
image: mysql:8
1197+
command: --sql_mode=STRICT_TRANS_TABLES --max_allowed_packet=512M
1198+
env:
1199+
MYSQL_ROOT_PASSWORD: test
1200+
ports:
1201+
- 3306:3306
1202+
```
1203+
1204+
## `jobs.<job_id>.services.<service_id>.entrypoint`
1205+
1206+
Overrides the Docker image's default `ENTRYPOINT`. The value is a single string defining the executable to run. Use this when you need to replace the image's entrypoint entirely. You can combine `entrypoint` with `command` to pass arguments to the custom entrypoint.
1207+
1208+
### Example of `jobs.<job_id>.services.<service_id>.entrypoint`
1209+
1210+
```yaml
1211+
services:
1212+
etcd:
1213+
image: quay.io/coreos/etcd:v3.5.17
1214+
entrypoint: etcd
1215+
command: >-
1216+
--listen-client-urls http://0.0.0.0:2379
1217+
--advertise-client-urls http://0.0.0.0:2379
1218+
ports:
1219+
- 2379:2379
1220+
```
1221+
1222+
{% endif %}
1223+
11851224
## `jobs.<job_id>.uses`
11861225

11871226
The location and version of a reusable workflow file to run as a job. Use one of the following syntaxes:

content/actions/tutorials/use-containerized-services/use-docker-service-containers.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,43 @@ jobs:
150150
151151
{% endraw %}
152152
153+
{% ifversion fpt or ghec %}
154+
155+
## Customizing service container entrypoints and commands
156+
157+
By default, service containers run with the entrypoint and command defined in the Docker image. You can override these using the `entrypoint` and `command` keys. This is useful when you need to pass flags to a service (such as a database) or swap the image entrypoint entirely, without building a custom wrapper image.
158+
159+
The `command` key overrides the image's default command (`CMD`). Most scenarios only need `command`—the image already has the right entrypoint, you just need to pass flags:
160+
161+
```yaml copy
162+
services:
163+
mysql:
164+
image: mysql:8
165+
command: --sql_mode=STRICT_TRANS_TABLES --max_allowed_packet=512M
166+
env:
167+
MYSQL_ROOT_PASSWORD: test
168+
ports:
169+
- 3306:3306
170+
```
171+
172+
The `entrypoint` key overrides the image's `ENTRYPOINT`. You can combine it with `command` to pass arguments to the custom entrypoint:
173+
174+
```yaml copy
175+
services:
176+
etcd:
177+
image: quay.io/coreos/etcd:v3.5.17
178+
entrypoint: etcd
179+
command: >-
180+
--listen-client-urls http://0.0.0.0:2379
181+
--advertise-client-urls http://0.0.0.0:2379
182+
ports:
183+
- 2379:2379
184+
```
185+
186+
The naming and behavior match Docker Compose. For more information, see [`jobs.<job_id>.services.<service_id>.command`](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idservicesservice_idcommand) and [`jobs.<job_id>.services.<service_id>.entrypoint`](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idservicesservice_identrypoint).
187+
188+
{% endif %}
189+
153190
## Further reading
154191

155192
* [AUTOTITLE](/actions/using-containerized-services/creating-redis-service-containers)

0 commit comments

Comments
 (0)