Skip to content

Commit 01143b7

Browse files
authored
small fixes to allow running localstack with podman (localstack#5124)
1 parent afe4407 commit 01143b7

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

localstack/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,13 @@ def in_docker():
579579
"""
580580
if OVERRIDE_IN_DOCKER:
581581
return True
582+
583+
# details: https://github.com/localstack/localstack/pull/4352
582584
if os.path.exists("/.dockerenv"):
583585
return True
586+
if os.path.exists("/run/.containerenv"):
587+
return True
588+
584589
if not os.path.exists("/proc/1/cgroup"):
585590
return False
586591
try:

localstack/services/awslambda/lambda_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from localstack.utils.aws import aws_stack
1515
from localstack.utils.aws.aws_models import LambdaFunction
1616
from localstack.utils.aws.aws_responses import flask_error_response_json
17-
from localstack.utils.common import in_docker, short_uid, to_str
17+
from localstack.utils.common import short_uid, to_str
1818
from localstack.utils.docker_utils import DOCKER_CLIENT
1919

2020
LOG = logging.getLogger(__name__)
@@ -157,7 +157,7 @@ def get_main_endpoint_from_container():
157157
if not config.HOSTNAME_FROM_LAMBDA and DOCKER_MAIN_CONTAINER_IP is None:
158158
DOCKER_MAIN_CONTAINER_IP = False
159159
try:
160-
if in_docker():
160+
if config.is_in_docker:
161161
DOCKER_MAIN_CONTAINER_IP = bootstrap.get_main_container_ip()
162162
LOG.info("Determined main container target IP: %s" % DOCKER_MAIN_CONTAINER_IP)
163163
except Exception as e:

localstack/utils/docker_utils.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ def _build_run_create_cmd(
882882
if mount_volumes:
883883
cmd += [
884884
volume
885-
for host_path, docker_path in mount_volumes
885+
for host_path, docker_path in dict(mount_volumes).items()
886886
for volume in ["-v", f"{host_path}:{docker_path}"]
887887
]
888888
if interactive:
@@ -1222,18 +1222,21 @@ def list_containers(self, filter: Union[List[str], str, None] = None, all=True)
12221222
LOG.debug("Listing containers with filters: %s", filter)
12231223
try:
12241224
container_list = self.client().containers.list(filters=filter, all=all)
1225-
return list(
1226-
map(
1227-
lambda container: {
1228-
"id": container.id,
1229-
"image": container.image,
1230-
"name": container.name,
1231-
"status": container.status,
1232-
"labels": container.labels,
1233-
},
1234-
container_list,
1235-
)
1236-
)
1225+
result = []
1226+
for container in container_list:
1227+
try:
1228+
result.append(
1229+
{
1230+
"id": container.id,
1231+
"image": container.image,
1232+
"name": container.name,
1233+
"status": container.status,
1234+
"labels": container.labels,
1235+
}
1236+
)
1237+
except Exception as e:
1238+
LOG.error(f"Error checking container {container}: {e}")
1239+
return result
12371240
except APIError:
12381241
raise ContainerException()
12391242

0 commit comments

Comments
 (0)