@@ -36,6 +36,7 @@ def main():
3636 create_parser = toplevel_parser .add_parser ("create" )
3737 create_parser .add_argument ("name" )
3838 create_parser .add_argument ("--image" , dest = "image" , default = None , required = False , help = "Choose image" )
39+ create_parser .add_argument ("-v" , dest = "volumes" , nargs = '*' , default = [], action = "extend" , help = "Add mounts" )
3940
4041 # Enter
4142 enter_parser = toplevel_parser .add_parser ("enter" )
@@ -84,7 +85,7 @@ def main():
8485
8586
8687 if args .command == "create" :
87- create (args .name , args .image )
88+ create (args .name , args .volumes , args . image )
8889 elif args .command == "enter" :
8990 enter (args .name )
9091 elif args .command in {"remove" ,"rm" ,"kill" }:
@@ -141,7 +142,7 @@ def get_image_name(image: str | None) -> str:
141142
142143
143144
144- def create (name : str , image : str | None ):
145+ def create (name : str , volumes : list [ str ], image : str | None ):
145146
146147 test = subprocess .run (
147148 [
@@ -162,6 +163,19 @@ def create(name: str, image: str | None):
162163
163164 print (f"Creating pwnbox with image '{ image } '" )
164165
166+ extra_mounts : list [str ] = []
167+
168+ for v in volumes :
169+ try :
170+ a ,b = v .split (":" ,maxsplit = 1 )
171+ except ValueError as e :
172+ print ("A mount requires a ':'" )
173+ sys .exit (1 )
174+
175+ host_path = pathlib .Path (a ).resolve ()
176+
177+ extra_mounts += ["-v" ,f"{ host_path } :{ b } " ]
178+
165179 hostname = f"pwnbox-{ name } "
166180 result = subprocess .run (
167181 [
@@ -176,6 +190,7 @@ def create(name: str, image: str | None):
176190 "-d" ,
177191 "-w" , "/mount/" ,
178192 "-v" , f"{ os .getcwd ()} :/mount/" ,
193+ * extra_mounts ,
179194 "--name" , f"{ name } " ,
180195 image ,
181196 "/bin/bash" ,
0 commit comments