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: content/reference/compose-file/services.md
+32-30Lines changed: 32 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -43,9 +43,9 @@ services:
43
43
POSTGRES_DB: exampledb
44
44
```
45
45
46
-
### Advanced example
46
+
### Advanced example
47
47
48
-
In the following example, the `proxy` service uses the Nginx image, mounts a local Nginx configuration file into the container, exposes port `80` and depends on the `backend` service.
48
+
In the following example, the `proxy` service uses the Nginx image, mounts a local Nginx configuration file into the container, exposes port `80` and depends on the `backend` service.
49
49
50
50
The `backend` service builds an image from the Dockerfile located in the `backend` directory that is set to build at stage `builder`.
51
51
@@ -376,7 +376,9 @@ credential_spec:
376
376
When using `registry:`, the credential spec is read from the Windows registry on
377
377
the daemon's host. A registry value with the given name must be located in:
The following example loads the credential spec from a value named `my-credential-spec`
382
384
in the registry:
@@ -668,7 +670,7 @@ env_file:
668
670
669
671
The `format` attribute lets you use an alternative file format for the `env_file`. When not set, `env_file` is parsed according to the Compose rules outlined in [`Env_file` format](#env_file-format).
670
672
671
-
`raw`format lets you use an `env_file` with key=value items, but without any attempt from Compose to parse the value for interpolation.
673
+
`raw`format lets you use an `env_file` with key=value items, but without any attempt from Compose to parse the value for interpolation.
672
674
This let you pass values as-is, including quotes and `$` signs.
673
675
674
676
```yml
@@ -760,7 +762,7 @@ expose:
760
762
761
763
> [!NOTE]
762
764
>
763
-
> If the Dockerfile for the image already exposes ports, it is visible to other containers on the network even if `expose` is not set in your Compose file.
765
+
> If the Dockerfile for the image already exposes ports, it is visible to other containers on the network even if `expose` is not set in your Compose file.
764
766
765
767
### `extends`
766
768
@@ -778,7 +780,7 @@ extends:
778
780
- `service`: Defines the name of the service being referenced as a base, for example `web` or `database`.
779
781
- `file`: The location of a Compose configuration file defining that service.
780
782
781
-
#### Restrictions
783
+
#### Restrictions
782
784
783
785
When a service is referenced using `extends`, it can declare dependencies on other resources. These dependencies may be explicitly defined through attributes like `volumes`, `networks`, `configs`, `secrets`, `links`, `volumes_from`, or `depends_on`. Alternatively, dependencies can reference another service using the `service:{name}` syntax in namespace declarations such as `ipc`, `pid`, or `network_mode`.
784
786
@@ -1022,7 +1024,7 @@ an implicit `gpu` capability.
1022
1024
```yaml
1023
1025
services:
1024
1026
model:
1025
-
gpus:
1027
+
gpus:
1026
1028
- driver: 3dfx
1027
1029
count: 2
1028
1030
```
@@ -1325,12 +1327,12 @@ If either is omitted, Compose automatically generates the environment variable n
1325
1327
1326
1328
### `network_mode`
1327
1329
1328
-
`network_mode`sets a service container's network mode.
1330
+
`network_mode`sets a service container's network mode.
1329
1331
1330
1332
- `none`: Turns off all container networking.
1331
1333
- `host`: Gives the container raw access to the host's network interface.
1332
-
- `service:{name}`: Gives the container access to the specified container by referring to its service name.
1333
-
- `container:{name}`: Gives the container access to the specified container by referring to its container ID.
1334
+
- `service:{name}`: Gives the container access to the specified container by referring to its service name.
1335
+
- `container:{name}`: Gives the container access to the specified container by referring to its container ID.
1334
1336
1335
1337
For more information container networks, see the [Docker Engine documentation](/manuals/engine/network/_index.md#container-networks).
1336
1338
@@ -1359,7 +1361,7 @@ For more information about the `networks` top-level element, see [Networks](netw
1359
1361
### Implicit default network
1360
1362
1361
1363
If `networks` is empty or absent from the Compose file, Compose considers an implicit definition for the service to be
1362
-
connected to the `default` network:
1364
+
connected to the `default` network:
1363
1365
1364
1366
```yml
1365
1367
services:
@@ -1371,9 +1373,9 @@ This example is actually equivalent to:
1371
1373
```yml
1372
1374
services:
1373
1375
some-service:
1374
-
image: foo
1376
+
image: foo
1375
1377
networks:
1376
-
default: {}
1378
+
default: {}
1377
1379
```
1378
1380
1379
1381
If you want the service to not be connected a network, you must set [`network_mode: none`](#network_mode).
@@ -1454,7 +1456,7 @@ services:
1454
1456
Running the example Compose application shows:
1455
1457
1456
1458
```console
1457
-
backend-1 | 11: eth0@if64: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
1459
+
backend-1 | 11: eth0@if64: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
1458
1460
```
1459
1461
1460
1462
#### `ipv4_address`, `ipv6_address`
@@ -1625,11 +1627,11 @@ in the form:
1625
1627
1626
1628
`[HOST:]CONTAINER[/PROTOCOL]` where:
1627
1629
1628
-
- `HOST`is `[IP:](port | range)` (optional). If it is not set, it binds to all network interfaces (`0.0.0.0`).
1630
+
- `HOST`is `[IP:](port | range)` (optional). If it is not set, it binds to all network interfaces (`0.0.0.0`).
1629
1631
- `CONTAINER`is `port | range`.
1630
1632
- `PROTOCOL`restricts ports to a specified protocol either `tcp` or `udp`(optional). Default is `tcp`.
1631
1633
1632
-
Ports can be either a single value or a range. `HOST` and `CONTAINER` must use equivalent ranges.
1634
+
Ports can be either a single value or a range. `HOST` and `CONTAINER` must use equivalent ranges.
1633
1635
1634
1636
You can either specify both ports (`HOST:CONTAINER`), or just the container port. In the latter case,
1635
1637
the container runtime automatically allocates any unassigned port of the host.
@@ -1650,10 +1652,10 @@ ports:
1650
1652
- "49100:22"
1651
1653
- "8000-9000:80"
1652
1654
- "127.0.0.1:8001:8001"
1653
-
- "127.0.0.1:5000-5010:5000-5010"
1654
-
- "::1:6000:6000"
1655
-
- "[::1]:6001:6001"
1656
-
- "6060:6060/udp"
1655
+
- "127.0.0.1:5000-5010:5000-5010"
1656
+
- "::1:6000:6000"
1657
+
- "[::1]:6001:6001"
1658
+
- "6060:6060/udp"
1657
1659
```
1658
1660
1659
1661
> [!NOTE]
@@ -1762,15 +1764,15 @@ services:
1762
1764
type: awesomecloud
1763
1765
options:
1764
1766
type: mysql
1765
-
foo: bar
1767
+
foo: bar
1766
1768
app:
1767
-
image: myapp
1769
+
image: myapp
1768
1770
depends_on:
1769
1771
- database
1770
1772
```
1771
1773
1772
-
As Compose runs the application, the `awesomecloud` binary is used to manage the `database` service setup.
1773
-
Dependent service `app` receives additional environment variables prefixed by the service name so it can access the resource.
1774
+
As Compose runs the application, the `awesomecloud` binary is used to manage the `database` service setup.
1775
+
Dependent service `app` receives additional environment variables prefixed by the service name so it can access the resource.
1774
1776
1775
1777
For illustration, assuming `awesomecloud` execution produced variables `URL` and `API_KEY`, the `app` service
1776
1778
runs with environment variables `DATABASE_URL` and `DATABASE_API_KEY`.
@@ -1906,7 +1908,7 @@ the service's containers.
1906
1908
- `mode`: The [permissions](https://wintelguy.com/permissions-calc.pl) for the file to be mounted in `/run/secrets/`
1907
1909
in the service's task containers, in octal notation.
1908
1910
The default value is world-readable permissions (mode `0444`).
1909
-
The writable bit must be ignored if set. The executable bit may be set.
1911
+
The writable bit must be ignored if set. The executable bit may be set.
1910
1912
1911
1913
Note that support for `uid`, `gid`, and `mode` attributes are not implemented in Docker Compose when the source of the secret is a [`file`](secrets.md). This is because bind-mounts used under the hood don't allow uid remapping.
1912
1914
@@ -1949,7 +1951,7 @@ It's specified as a [byte value](extension.md#specifying-byte-values).
1949
1951
1950
1952
### `stdin_open`
1951
1953
1952
-
`stdin_open`configures a service's container to run with an allocated stdin. This is the same as running a container with the
1954
+
`stdin_open`configures a service's container to run with an allocated stdin. This is the same as running a container with the
1953
1955
`-i`flag. For more information, see [Keep stdin open](/reference/cli/docker/container/run.md#interactive).
1954
1956
1955
1957
Supported values are `true` or `false`.
@@ -2036,7 +2038,7 @@ services:
2036
2038
2037
2039
### `tty`
2038
2040
2039
-
`tty`configures a service's container to run with a TTY. This is the same as running a container with the
2041
+
`tty`configures a service's container to run with a TTY. This is the same as running a container with the
2040
2042
`-t`or `--tty` flag. For more information, see [Allocate a pseudo-TTY](/reference/cli/docker/container/run.md#tty).
2041
2043
2042
2044
Supported values are `true` or `false`.
@@ -2140,7 +2142,7 @@ The short syntax uses a single string with colon-separated values to specify a v
2140
2142
2141
2143
> [!NOTE]
2142
2144
>
2143
-
> For bind mounts, the short syntax creates a directory at the source path on the host if it doesn't exist. This is for backward compatibility with `docker-compose` legacy.
2145
+
> For bind mounts, the short syntax creates a directory at the source path on the host if it doesn't exist. This is for backward compatibility with `docker-compose` legacy.
2144
2146
> It can be prevented by using long syntax and setting `create_host_path` to `false`.
2145
2147
2146
2148
#### Long syntax
@@ -2170,8 +2172,8 @@ expressed in the short form.
2170
2172
2171
2173
> [!TIP]
2172
2174
>
2173
-
> Working with large repositories or monorepos, or with virtual file systems that are no longer scaling with your codebase?
2174
-
> Compose now takes advantage of [Synchronized file shares](/manuals/desktop/features/synchronized-file-sharing.md) and automatically creates file shares for bind mounts.
2175
+
> Working with large repositories or monorepos, or with virtual file systems that are no longer scaling with your codebase?
2176
+
> Compose now takes advantage of [Synchronized file shares](/manuals/desktop/features/synchronized-file-sharing.md) and automatically creates file shares for bind mounts.
2175
2177
> Ensure you're signed in to Docker with a paid subscription and have enabled both **Access experimental features** and **Manage Synchronized file shares with Compose** in Docker Desktop's settings.
0 commit comments