Debian Codegraph @

docs/Extensions.md

raw symbols SCIP
1 # Podman specific extensions to the docker-compose format
2
3 Podman-compose supports the following extensions to the docker-compose format. These extensions
4 are generally specified under fields with "x-podman" prefix in the compose file.
5
6 ## Container management
7
8 The following extension keys are available under container configuration:
9
10 * `x-podman.uidmaps` - Run the container in a new user namespace using the supplied UID mapping.
11
12 * `x-podman.gidmaps` - Run the container in a new user namespace using the supplied GID mapping.
13
14 * `x-podman.rootfs` - Run the container without requiring any image management; the rootfs of the
15 container is assumed to be managed externally.
16
17 * `x-podman.no_hosts` - Run the container without creating /etc/hosts file
18
19 For example, the following docker-compose.yml allows running a podman container with externally managed rootfs.
20 ```yml
21 version: "3"
22 services:
23 my_service:
24 command: ["/bin/busybox"]
25 x-podman.rootfs: "/path/to/rootfs"
26 ```
27
28 For explanations of these extensions, please refer to the [Podman Documentation](https://docs.podman.io/).
29
30 ## Secrets
31 The following extension keys are available under `secret` configuration:
32
33 x-podman.relabel - Configure SELinux relabeling
34
35 For example, the following configures custom-secret to use mount with private and unshared content.
36 Only the current container can use a private volume.
37
38 ```yml
39 secrets:
40 custom-secret:
41 x-podman.relabel: Z
42 ```
43
44 For explanations of these extensions, please refer to the [podman-run --volume documentation](https://docs.podman.io/en/latest/markdown/podman-run.1.html#volume-v-source-volume-host-dir-container-dir-options)).
45
46 ## Network management
47
48 The following extension keys are available under network configuration:
49
50 * `x-podman.disable_dns` - Disable the DNS plugin for the network when set to 'true'.
51 * `x-podman.dns` - Specifies a list of nameservers for the network. This cannot be used with x-podman.disable_dns`.
52
53 For example, the following docker-compose.yml allows all containers on the same network to use the
54 specified nameservers:
55 ```yml
56 version: "3"
57 network:
58 my_network:
59 x-podman.dns:
60 - "10.1.2.3"
61 - "10.1.2.4"
62 ```
63
64 * `x-podman.routes` - Specifies a list of additional routes for the network. This corresponds to
65 `--route` option in `podman network create`.
66
67 For example, the following docker-compose.yml blocks network connectivity to specified subnet from
68 all containers on the network:
69 ```yml
70 version: "3"
71 network:
72 my_network:
73 x-podman.routes:
74 - "10.2.3.4,127.0.0.1"
75 ```
76
77 For explanations of these extensions, please refer to the
78 [Podman network create command Documentation](https://docs.podman.io/en/latest/markdown/podman-network-create.1.html).
79
80 ## Per-network MAC-addresses
81
82 Generic docker-compose files support specification of the MAC address on the container level. If the
83 container has multiple network interfaces, the specified MAC address is applied to the first
84 specified network.
85
86 Podman-compose in addition supports the specification of MAC addresses on a per-network basis. This
87 is done by adding a `x-podman.mac_address` key to the network configuration in the container. The
88 value of the `x-podman.mac_address` key is the MAC address to be used for the network interface.
89
90 Note that the [compose spec](https://github.com/compose-spec/compose-spec/blob/main/05-services.md#mac_address)
91 now supports `mac_address` on the network level, so we recommend using
92 the standard `mac_address` key for setting the MAC address. The
93 `x-podman.mac_address` is still supported for backwards compatibility.
94
95
96 Specifying a MAC address for the container and for individual networks at the same time is not
97 supported.
98
99 Example:
100
101 ```yaml
102 ---
103 version: "3"
104
105 networks:
106 net0:
107 driver: "bridge"
108 ipam:
109 config:
110 - subnet: "192.168.0.0/24"
111 net1:
112 driver: "bridge"
113 ipam:
114 config:
115 - subnet: "192.168.1.0/24"
116
117 services:
118 webserver:
119 image: "busybox"
120 command: ["/bin/busybox", "httpd", "-f", "-h", "/etc", "-p", "8001"]
121 networks:
122 net0:
123 ipv4_address: "192.168.0.10"
124 x-podman.mac_address: "02:aa:aa:aa:aa:aa"
125 net1:
126 ipv4_address: "192.168.1.10"
127 mac_address: "02:bb:bb:bb:bb:bb" # mac_address is supported
128 ```
129
130 ## Per-network interface name
131
132 Using `x-podman.interface_name` within a container's network config you can specify the interface name inside the container.
133
134 ## Podman-specific network modes
135
136 Generic docker-compose supports the following values for `network-mode` for a container:
137
138 - `bridge`
139 - `host`
140 - `none`
141 - `service`
142 - `container`
143
144 In addition, podman-compose supports the following podman-specific values for `network-mode`:
145
146 - `slirp4netns[:<options>,...]`
147 - `ns:<options>`
148 - `pasta[:<options>,...]`
149 - `private`
150
151 The options to the network modes are passed to the `--network` option of the `podman create` command
152 as-is.
153
154 ## Podman-specific mount types
155
156 Generic docker-compose supports the following values for mount `type`:
157
158 - `volume`
159 - `bind`
160 - `tmpfs`
161
162 In addition, podman-compose supports the following podman-specific values for mount `type`:
163
164 - `glob`
165
166 ## Docker Compose Compatibility
167
168 podman-compose aims to be compatible with docker-compose, but there are some differences in
169 behavior and features. The following sections describe how to enable compatibility with docker-compose
170 and how to handle some of the differences.
171
172 Compatibility settings can either be set explicitly as described below, or by setting the `docker_compose_compat` meta
173 settings to `true` under the global `x-podman` key:
174
175 ```yaml
176 x-podman:
177 docker_compose_compat: true
178 ```
179
180 This will enable all compatibility settings described below, and is equivalent to setting each of them to `true`.
181
182 This setting can also be changed by setting the `PODMAN_COMPOSE_DOCKER_COMPOSE_COMPAT` environment variable.
183
184 ## Compatibility of name separators between docker-compose and podman-compose
185
186 Currently, podman-compose is using underscores (`_` character) as a separator in names of
187 containers, images, etc., while docker-compose has switched to hyphens (`-` character). This setting
188 allows you to switch podman-compose to use hyphens as well.
189
190 To enable compatibility between docker-compose and podman-compose, specify
191 `name_separator_compat: true` under global `x-podman` key:
192
193 ```
194 x-podman:
195 name_separator_compat: true
196 ```
197
198 By default `name_separator_compat` is `false`. This will change to `true` at some point and the
199 setting will be removed.
200
201 This setting can also be changed by setting `PODMAN_COMPOSE_NAME_SEPARATOR_COMPAT` environment
202 variable.
203
204 ## Compatibility of default network names between docker-compose and podman-compose
205
206 Current versions of podman-compose may produce different default external network names than
207 docker-compose under certain conditions. Specifically, docker-compose removes dashes (`-` character)
208 from project name.
209
210 To enable compatibility between docker-compose and podman-compose, specify
211 `default_net_name_compat: true` under global `x-podman` key:
212
213 ```
214 x-podman:
215 default_net_name_compat: true
216 ```
217
218 By default `default_net_name_compat` is `false`. This will change to `true` at some point and the
219 setting will be removed.
220
221 This setting can also be changed by setting `PODMAN_COMPOSE_DEFAULT_NET_NAME_COMPAT` environment
222 variable.
223
224 ## Compatibility of default network behavior between docker-compose and podman-compose
225
226 When there is no network defined (neither network-mode nor networks) in service,
227 The behavior of default network in docker-compose and podman-compose is different.
228
229 | Top-level networks | podman-compose | docker-compose |
230 | ------------------------------ | -------------------------- | -------------- |
231 | No networks | default | default |
232 | One network named net0 | net0 | default |
233 | Two networks named net0, net1 | podman(`--network=bridge`) | default |
234 | Contains network named default | default | default |
235
236 To enable compatibility between docker-compose and podman-compose, specify
237 `default_net_behavior_compat: true` under global `x-podman` key:
238
239 ```yaml
240 x-podman:
241 default_net_behavior_compat: true
242 ```
243
244 This setting can also be changed by setting `PODMAN_COMPOSE_DEFAULT_NET_BEHAVIOR_COMPAT` environment
245 variable.
246
247 ## Custom pods management
248
249 Podman-compose can have containers in pods. This can be controlled by the extension key x-podman in_pod.
250 It allows providing a custom value for --in-pod and is especially relevant when --userns has to be set.
251
252 For example, the following docker-compose.yml allows using userns_mode by overriding the default
253 value of --in-pod (unless it was specifically provided by "--in-pod=True" in command line interface).
254 ```yml
255 version: "3"
256 services:
257 cont:
258 image: nopush/podman-compose-test
259 userns_mode: keep-id:uid=1000
260 command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-p", "8080"]
261
262 x-podman:
263 in_pod: false
264 ```
265
266 This setting can also be changed by setting `PODMAN_COMPOSE_IN_POD` environment
267 variable.
268
269 It is also possible to override the default arguments for pod creation that are
270 used when --pod-args is not passed on the command line:
271 ```yml
272 version: "3"
273 services:
274 cont:
275 image: nopush/podman-compose-test
276 command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-p", "8080"]
277 x-podman:
278 pod_args: ["--infra=false", "--share=", "--cpus=1"]
279 ```
280 When not set in docker-compose.yml or on the command line, the pod args default
281 to `["--infra=false", "--share="]`.
282
283 This setting can also be changed by setting `PODMAN_COMPOSE_POD_ARGS` environment
284 variable.