mirror of
https://github.com/containers/podman-compose.git
synced 2025-01-12 08:58:32 +01:00
Migrate x-podman dictionary to x-podman.* fields in container root
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
parent
0a6c057486
commit
9599cc039e
@ -1,6 +1,30 @@
|
||||
# Podman specific extensions to the docker-compose format
|
||||
|
||||
Podman-compose supports the following extension to the docker-compose format.
|
||||
Podman-compose supports the following extension to the docker-compose format. These extensions
|
||||
are generally specified under fields with "x-podman" prefix in the compose file.
|
||||
|
||||
## Container management
|
||||
|
||||
The following extension keys are available under container configuration:
|
||||
|
||||
* `x-podman.uidmap` - Run the container in a new user namespace using the supplied UID mapping.
|
||||
|
||||
* `x-podman.gidmap` - Run the container in a new user namespace using the supplied GID mapping.
|
||||
|
||||
* `x-podman.rootfs` - Run the container without requiring any image management; the rootfs of the
|
||||
container is assumed to be managed externally.
|
||||
|
||||
For example, the following docker-compose.yml allows running a podman container with externally managed rootfs.
|
||||
```yml
|
||||
version: "3"
|
||||
services:
|
||||
my_service:
|
||||
command: ["/bin/busybox"]
|
||||
x-podman.rootfs: "/path/to/rootfs"
|
||||
```
|
||||
|
||||
For explanations of these extensions, please refer to the [Podman Documentation](https://docs.podman.io/).
|
||||
|
||||
|
||||
## Per-network MAC-addresses
|
||||
|
||||
@ -65,27 +89,3 @@ In addition, podman-compose supports the following podman-specific values for `n
|
||||
|
||||
The options to the network modes are passed to the `--network` option of the `podman create` command
|
||||
as-is.
|
||||
|
||||
# Service management
|
||||
|
||||
Podman-compose extends the compose specification to support some unique features of Podman. These extensions can be specified in the compose file under the "x-podman" field.
|
||||
|
||||
Currently, podman-compose supports the following extensions:
|
||||
|
||||
* `uidmap` - Run the container in a new user namespace using the supplied UID mapping.
|
||||
|
||||
* `gidmap` - Run the container in a new user namespace using the supplied GID mapping.
|
||||
|
||||
* `rootfs` - Run the container without requiring any image management; the rootfs of the container is assumed to be managed externally.
|
||||
|
||||
For example, the following docker-compose.yml allows running a podman container with externally managed rootfs.
|
||||
```yml
|
||||
version: "3"
|
||||
services:
|
||||
my_service:
|
||||
command: ["/bin/busybox"]
|
||||
x-podman:
|
||||
rootfs: "/path/to/rootfs"
|
||||
```
|
||||
|
||||
For explanations of these extensions, please refer to the [Podman Documentation](https://docs.podman.io/).
|
||||
|
@ -1144,21 +1144,22 @@ async def container_to_args(compose, cnt, detached=True):
|
||||
podman_args.extend(["--healthcheck-retries", str(healthcheck["retries"])])
|
||||
|
||||
# handle podman extension
|
||||
x_podman = cnt.get("x-podman", None)
|
||||
if 'x-podman' in cnt:
|
||||
raise ValueError(
|
||||
'Configuration under x-podman has been migrated to x-podman.uidmap and '
|
||||
'x-podman.gidman fields'
|
||||
)
|
||||
|
||||
rootfs_mode = False
|
||||
if x_podman is not None:
|
||||
for uidmap in x_podman.get("uidmaps", []):
|
||||
for uidmap in cnt.get('x-podman.uidmaps', []):
|
||||
podman_args.extend(["--uidmap", uidmap])
|
||||
for gidmap in x_podman.get("gidmaps", []):
|
||||
for gidmap in cnt.get('x-podman.gidmaps', []):
|
||||
podman_args.extend(["--gidmap", gidmap])
|
||||
rootfs = x_podman.get("rootfs", None)
|
||||
rootfs = cnt.get('x-podman.rootfs', None)
|
||||
if rootfs is not None:
|
||||
rootfs_mode = True
|
||||
podman_args.extend(["--rootfs", rootfs])
|
||||
log.warning(
|
||||
"WARNING: x-podman.rootfs and image both specified, \
|
||||
image field ignored"
|
||||
)
|
||||
log.warning("WARNING: x-podman.rootfs and image both specified, image field ignored")
|
||||
|
||||
if not rootfs_mode:
|
||||
podman_args.append(cnt["image"]) # command, ..etc.
|
||||
|
@ -162,14 +162,21 @@ class TestContainerToArgs(unittest.IsolatedAsyncioTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
async def test_uidmaps_extension_old_path(self):
|
||||
c = create_compose_mock()
|
||||
|
||||
cnt = get_minimal_container()
|
||||
cnt['x-podman'] = {'uidmaps': ['1000:1000:1']}
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
await container_to_args(c, cnt)
|
||||
|
||||
async def test_rootfs_extension(self):
|
||||
c = create_compose_mock()
|
||||
|
||||
cnt = get_minimal_container()
|
||||
del cnt["image"]
|
||||
cnt["x-podman"] = {
|
||||
"rootfs": "/path/to/rootfs",
|
||||
}
|
||||
cnt["x-podman.rootfs"] = "/path/to/rootfs"
|
||||
|
||||
args = await container_to_args(c, cnt)
|
||||
self.assertEqual(
|
||||
|
Loading…
Reference in New Issue
Block a user