Skip to content

Commit a75998b

Browse files
committed
Add privileged parameter to create sandbox, default to false
1 parent 1ce139d commit a75998b

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

docs/sandbox.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,8 @@ def create(cls,
988988
api_token: Optional[str] = None,
989989
timeout: int = 300,
990990
idle_timeout: Optional[IdleTimeout] = None,
991-
enable_tcp_proxy: bool = False) -> Sandbox
991+
enable_tcp_proxy: bool = False,
992+
privileged: bool = False) -> Sandbox
992993
```
993994

994995
Create a new sandbox instance.
@@ -1012,6 +1013,7 @@ Create a new sandbox instance.
10121013
- int > 0: Deep sleep only (e.g., 600 for 600s deep sleep)
10131014
- dict: Explicit configuration with {"light_sleep": 300, "deep_sleep": 600}
10141015
- `enable_tcp_proxy` - If True, enables TCP proxy for direct TCP access to port 3031
1016+
- `privileged` - If True, run the container in privileged mode (default: False)
10151017

10161018

10171019
**Returns**:
@@ -1455,7 +1457,8 @@ async def create(cls,
14551457
api_token: Optional[str] = None,
14561458
timeout: int = 300,
14571459
idle_timeout: Optional[IdleTimeout] = None,
1458-
enable_tcp_proxy: bool = False) -> AsyncSandbox
1460+
enable_tcp_proxy: bool = False,
1461+
privileged: bool = False) -> AsyncSandbox
14591462
```
14601463

14611464
Create a new sandbox instance with async support.
@@ -1479,6 +1482,7 @@ Create a new sandbox instance with async support.
14791482
- int > 0: Deep sleep only (e.g., 600 for 600s deep sleep)
14801483
- dict: Explicit configuration with {"light_sleep": 300, "deep_sleep": 600}
14811484
- `enable_tcp_proxy` - If True, enables TCP proxy for direct TCP access to port 3031
1485+
- `privileged` - If True, run the container in privileged mode (default: False)
14821486

14831487

14841488
**Returns**:

koyeb/sandbox/sandbox.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def create(
113113
timeout: int = 300,
114114
idle_timeout: Optional[IdleTimeout] = None,
115115
enable_tcp_proxy: bool = False,
116+
privileged: bool = False,
116117
) -> Sandbox:
117118
"""
118119
Create a new sandbox instance.
@@ -135,6 +136,7 @@ def create(
135136
- int > 0: Deep sleep only (e.g., 600 for 600s deep sleep)
136137
- dict: Explicit configuration with {"light_sleep": 300, "deep_sleep": 600}
137138
enable_tcp_proxy: If True, enables TCP proxy for direct TCP access to port 3031
139+
privileged: If True, run the container in privileged mode (default: False)
138140
139141
Returns:
140142
Sandbox: A new Sandbox instance
@@ -161,6 +163,7 @@ def create(
161163
timeout=timeout,
162164
idle_timeout=idle_timeout,
163165
enable_tcp_proxy=enable_tcp_proxy,
166+
privileged=privileged,
164167
)
165168

166169
if wait_ready:
@@ -187,6 +190,7 @@ def _create_sync(
187190
timeout: int = 300,
188191
idle_timeout: Optional[IdleTimeout] = None,
189192
enable_tcp_proxy: bool = False,
193+
privileged: bool = False,
190194
) -> Sandbox:
191195
"""
192196
Synchronous creation method that returns creation parameters.
@@ -215,7 +219,7 @@ def _create_sync(
215219
app_id = app_response.app.id
216220

217221
env_vars = build_env_vars(env)
218-
docker_source = create_docker_source(image, [], privileged=True)
222+
docker_source = create_docker_source(image, [], privileged=privileged)
219223
deployment_definition = create_deployment_definition(
220224
name=name,
221225
docker_source=docker_source,
@@ -848,6 +852,7 @@ async def create(
848852
timeout: int = 300,
849853
idle_timeout: Optional[IdleTimeout] = None,
850854
enable_tcp_proxy: bool = False,
855+
privileged: bool = False,
851856
) -> AsyncSandbox:
852857
"""
853858
Create a new sandbox instance with async support.
@@ -870,6 +875,7 @@ async def create(
870875
- int > 0: Deep sleep only (e.g., 600 for 600s deep sleep)
871876
- dict: Explicit configuration with {"light_sleep": 300, "deep_sleep": 600}
872877
enable_tcp_proxy: If True, enables TCP proxy for direct TCP access to port 3031
878+
privileged: If True, run the container in privileged mode (default: False)
873879
874880
Returns:
875881
AsyncSandbox: A new AsyncSandbox instance
@@ -899,6 +905,7 @@ async def create(
899905
timeout=timeout,
900906
idle_timeout=idle_timeout,
901907
enable_tcp_proxy=enable_tcp_proxy,
908+
privileged=privileged,
902909
),
903910
)
904911

0 commit comments

Comments
 (0)