summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2021-11-28 20:34:07 +0100
committerMatej Vasek <mvasek@redhat.com>2021-11-29 15:57:56 +0100
commit697ff213dd36b78a4857c07b4c6a82246d0a875f (patch)
tree172350015451a7759d0a385aa66dc16b8b9c50a3
parent3d19f1a7fac5705518693cad3f2c7f94dcc2f1d4 (diff)
downloadpodman-697ff213dd36b78a4857c07b4c6a82246d0a875f.tar.gz
podman-697ff213dd36b78a4857c07b4c6a82246d0a875f.tar.bz2
podman-697ff213dd36b78a4857c07b4c6a82246d0a875f.zip
fix: parsing of HostConfig.Mounts for container create
Signed-off-by: Matej Vasek <mvasek@redhat.com>
-rw-r--r--cmd/podman/common/create_opts.go4
-rw-r--r--test/python/docker/compat/test_containers.py25
2 files changed, 27 insertions, 2 deletions
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index aacdfd274..abb55f8c7 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -103,7 +103,9 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
addField(&builder, "type", string(m.Type))
addField(&builder, "source", m.Source)
addField(&builder, "target", m.Target)
- addField(&builder, "ro", strconv.FormatBool(m.ReadOnly))
+ if m.ReadOnly {
+ addField(&builder, "ro", "true")
+ }
addField(&builder, "consistency", string(m.Consistency))
// Map any specialized mount options that intersect between *Options and cli options
switch m.Type {
diff --git a/test/python/docker/compat/test_containers.py b/test/python/docker/compat/test_containers.py
index d6eacd560..d14c09fc1 100644
--- a/test/python/docker/compat/test_containers.py
+++ b/test/python/docker/compat/test_containers.py
@@ -3,12 +3,13 @@ import subprocess
import sys
import time
import unittest
-from typing import IO, Optional
+from typing import IO, Optional, List
from docker import DockerClient, errors
from docker.models.containers import Container
from docker.models.images import Image
from docker.models.volumes import Volume
+from docker.types import Mount
from test.python.docker import Podman
from test.python.docker.compat import common, constant
@@ -277,3 +278,25 @@ class TestContainers(unittest.TestCase):
ctr.start()
ret, out = ctr.exec_run(["stat", "/workspace/scratch/test"])
self.assertEqual(ret, 0, "Working directory created if it doesn't exist")
+
+ def test_mount_rw_by_default(self):
+ ctr: Optional[Container] = None
+ vol: Optional[Volume] = None
+ try:
+ vol = self.client.volumes.create("test-volume")
+ ctr = self.client.containers.create(image="alpine",
+ detach=True,
+ command="top",
+ mounts=[Mount(target="/vol-mnt",
+ source="test-volume",
+ type='volume',
+ read_only=False)])
+ ctr_inspect = self.client.api.inspect_container(ctr.id)
+ binds: List[str] = ctr_inspect["HostConfig"]["Binds"]
+ self.assertEqual(len(binds), 1)
+ self.assertEqual(binds[0], 'test-volume:/vol-mnt:rw,rprivate,nosuid,nodev,rbind')
+ finally:
+ if ctr is not None:
+ ctr.remove()
+ if vol is not None:
+ vol.remove(force=True)