@@ -19,19 +19,25 @@ def __init__(self, docker_client: docker.DockerClient):
1919
2020 version_info = self .docker_client .version ()
2121 server_version = version_info .get ('Version' , '' ).replace ('-' , '.' )
22- if tuple (map (int , server_version .split ('.' )[:2 ])) < (18 , 9 ):
22+ self .is_podman = version_info .get ('Components' )[0 ].get ('Name' ).startswith ('Podman' )
23+ if tuple (map (int , server_version .split ('.' )[:2 ])) < (18 , 9 ) and not self .is_podman :
2324 raise AgentRuntimeBuildError (
2425 'Docker server version must be >= 18.09 to use BuildKit'
2526 )
2627
28+ if self .is_podman and tuple (map (int , server_version .split ('.' )[:2 ])) < (4 , 9 ):
29+ raise AgentRuntimeBuildError (
30+ 'Podman server version must be >= 4.9.0'
31+ )
32+
2733 self .rolling_logger = RollingLogger (max_lines = 10 )
2834
2935 @staticmethod
30- def check_buildx ():
36+ def check_buildx (is_podman : bool = False ):
3137 """Check if Docker Buildx is available"""
3238 try :
3339 result = subprocess .run (
34- ['docker' , 'buildx' , 'version' ], capture_output = True , text = True
40+ ['docker' if not is_podman else 'podman' , 'buildx' , 'version' ], capture_output = True , text = True
3541 )
3642 return result .returncode == 0
3743 except FileNotFoundError :
@@ -68,12 +74,18 @@ def build(
6874 self .docker_client = docker .from_env ()
6975 version_info = self .docker_client .version ()
7076 server_version = version_info .get ('Version' , '' ).split ('+' )[0 ].replace ('-' , '.' )
71- if tuple (map (int , server_version .split ('.' ))) < (18 , 9 ):
77+ self .is_podman = version_info .get ('Components' )[0 ].get ('Name' ).startswith ('Podman' )
78+ if tuple (map (int , server_version .split ('.' ))) < (18 , 9 ) and not self .is_podman :
7279 raise AgentRuntimeBuildError (
7380 'Docker server version must be >= 18.09 to use BuildKit'
7481 )
7582
76- if not DockerRuntimeBuilder .check_buildx ():
83+ if self .is_podman and tuple (map (int , server_version .split ('.' ))) < (4 , 9 ):
84+ raise AgentRuntimeBuildError (
85+ 'Podman server version must be >= 4.9.0'
86+ )
87+
88+ if not DockerRuntimeBuilder .check_buildx (self .is_podman ):
7789 # when running openhands in a container, there might not be a "docker"
7890 # binary available, in which case we need to download docker binary.
7991 # since the official openhands app image is built from debian, we use
@@ -110,7 +122,7 @@ def build(
110122 target_image_tag = tags [1 ].split (':' )[1 ] if len (tags ) > 1 else None
111123
112124 buildx_cmd = [
113- 'docker' ,
125+ 'docker' if not self . is_podman else 'podman' ,
114126 'buildx' ,
115127 'build' ,
116128 '--progress=plain' ,
@@ -139,7 +151,7 @@ def build(
139151 buildx_cmd .append (path ) # must be last!
140152
141153 self .rolling_logger .start (
142- '================ DOCKER BUILD STARTED ================'
154+ f '================ { buildx_cmd [ 0 ]. upper () } BUILD STARTED ================'
143155 )
144156
145157 try :
0 commit comments