Docker in Docker for wandb agent
Intro#
Like portainer, to isolate the wand-agent runtime environment inside container(dockernize) without losing the ability to fully access host resources(commence docker run), we must expose the host docker socket to the wandb-agent container.
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
Note: Privillage flag is not necessarily required at this stage.
Self-host#
To slim down the image size, I personally prefer a portable static binary file /docker
form portainer-ce:latest
image instead of installing by apt install docker.io
inside Dockerfile (too much disk space consumption).
FROM python:3.9.19-slim
RUN pip install wandb[launch]
# Docker version 20.10.21, build 20.10.21-0ubuntu1~22.04.3
COPY docker /bin/docker
# separate two RUN for better layer cache reuse policy
RUN wandb login --relogin --host http://192.168.1.3:8080 local-af185xxxxxxxx
ENTRYPOINT ["wandb", "launch-agent", "-e", "xxxxx", "-q", "test-queue"]
Explore#
In real production, an S6 daemon service may be required to keep agent backend alive?
It seems --restart=always
policy is enough, since wandb is already the pid1 process, the entrypoint shares the same lifecycle as container does.
docker run -d --restart always --name wandb-agent --hostname agent-3070 \
-v /var/run/docker.sock:/var/run/docker.sock wandb-agent:test-queue
The key is to share host docker.sock to the guest.
Note: Lower docker version may not support --gpus
params in run, better align with host.
Ref#
Install Portainer CE with Docker on Linux | 2.19 | Portainer Documentation
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
2022-05-09 emplace_back无法支持<brace-enclosed initializer list>吗?
2022-05-09 C++报错undefined reference to vtable处理