in the service's task containers, in octal notation.
The default value is world-readable permissions (mode `0444`).
The writable bit must be ignored if set. The executable bit may be set.
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.
The following example sets the name of the `server-certificate` secret file to `server.cert`
within the container, sets the mode to `0440` (group-readable), and sets the user and group
to `103`. The value of `server-certificate` is set
to the contents of the file `./server.cert`.
```yml
services:
frontend:
image: example/webapp
secrets:
- source: server-certificate
target: server.cert
uid: "103"
gid: "103"
mode: 0o440
secrets:
server-certificate:
file: ./server.cert
```
### `security_opt`
`security_opt` overrides the default labeling scheme for each container.
```yml
security_opt:
- label=user:USER
- label=role:ROLE
```
For further default labeling schemes you can override, see [Security configuration](/reference/cli/docker/container/run.md#security-opt).
### `shm_size`
`shm_size` configures the size of the shared memory (`/dev/shm` partition on Linux) allowed by the service container.
It's specified as a [byte value](extension.md#specifying-byte-values).
### `stdin_open`
`stdin_open` configures a service's container to run with an allocated stdin. This is the same as running a container with the
`-i` flag. For more information, see [Keep stdin open](/reference/cli/docker/container/run.md#interactive).
Supported values are `true` or `false`.
### `stop_grace_period`
`stop_grace_period` specifies how long Compose must wait when attempting to stop a container if it doesn't
handle SIGTERM (or whichever stop signal has been specified with
[`stop_signal`](#stop_signal)), before sending SIGKILL. It's specified
as a [duration](extension.md#specifying-durations).
```yml
stop_grace_period: 1s
stop_grace_period: 1m30s
```
Default value is 10 seconds for the container to exit before sending SIGKILL.
### `stop_signal`
`stop_signal` defines the signal that Compose uses to stop the service containers.
If unset containers are stopped by Compose by sending `SIGTERM`.
```yml
stop_signal: SIGUSR1
```
### `storage_opt`
`storage_opt` defines storage driver options for a service.
```yml
storage_opt:
size: '1G'
```
### `sysctls`
`sysctls` defines kernel parameters to set in the container. `sysctls` can use either an array or a map.
```yml
sysctls:
net.core.somaxconn: 1024
net.ipv4.tcp_syncookies: 0
```
```yml
sysctls:
- net.core.somaxconn=1024
- net.ipv4.tcp_syncookies=0
```
You can only use sysctls that are namespaced in the kernel. Docker does not
support changing sysctls inside a container that also modify the host system.
For an overview of supported sysctls, refer to [configure namespaced kernel
parameters (sysctls) at runtime](/reference/cli/docker/container/run.md#sysctl).
### `tmpfs`
`tmpfs` mounts a temporary file system inside the container. It can be a single value or a list.
```yml
tmpfs:
- <path>
- <path>:<options>
```
- `path`: The path inside the container where the tmpfs will be mounted.
- `options`: Comma-separated list of options for the tmpfs mount.
Available options:
- `mode`: Sets the file system permissions.
- `uid`: Sets the user ID that owns the mounted tmpfs.
- `gid`: Sets the group ID that owns the mounted tmpfs.
```yml
services:
app:
tmpfs:
- /data:mode=755,uid=1009,gid=1009
- /run
```
### `tty`
`tty` configures a service's container to run with a TTY. This is the same as running a container with the
`-t` or `--tty` flag. For more information, see [Allocate a pseudo-TTY](/reference/cli/docker/container/run.md#tty).
Supported values are `true` or `false`.
### `ulimits`
`ulimits` overrides the default `ulimits` for a container. It's specified either as an integer for a single limit