-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Unable to use local Docker images
my image is my-python-slim:latest
import asyncio
import os
from boxlite import CodeBox
# 自动获取当前项目下 project/001 的绝对路径
HOST_PROJECT_DIR = os.path.abspath("./project/001")
GUEST_WORKDIR = "/workspace"
async def main():
# 使用 CodeBox 简化配置
# volumes 和 working_dir 会自动传递给底层的 BoxOptions
async with CodeBox(
image="my-python-slim:latest",
volumes=[{"host": HOST_PROJECT_DIR, "guest": GUEST_WORKDIR, "read_only": False}],
working_dir=GUEST_WORKDIR
) as codebox:
print(f"Box 已启动,挂载目录: {HOST_PROJECT_DIR}")
# 在沙盒里运行 myscript.py
print("\n正在运行 myscript.py...")
res = await codebox.exec("python", "/workspace/myscript.py")
print(f"脚本退出码: {res.exit_code}")
if res.stdout:
print(f"脚本输出 (stdout):\n{res.stdout}")
if res.stderr:
print(f"脚本错误 (stderr):\n{res.stderr}")
if __name__ == "__main__":
asyncio.run(main())
but It still pulls image
(excel-report) liuyingduo@ubuntu:~/study/excel_report$ python run_in_box.py
Box 已启动,挂载目录: /home/liuyingduo/study/excel_report/project/001
正在运行 myscript.py...
Traceback (most recent call last):
File "/home/liuyingduo/study/excel_report/run_in_box.py", line 30, in <module>
asyncio.run(main())
File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/liuyingduo/study/excel_report/run_in_box.py", line 21, in main
res = await codebox.exec("python", "/workspace/myscript.py")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/liuyingduo/study/excel_report/.venv/lib/python3.12/site-packages/boxlite/simplebox.py", line 141, in exec
execution = await self._box.exec(cmd, arg_list, env_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: storage error: failed to pull manifest: Not authorized: url https://index.docker.io/v2/library/my-python-slim/manifests/latest
Metadata
Metadata
Assignees
Labels
No labels