Github 提供免费构建容器的核时额度,支持一个self-host 构建节点。
Jenkens 开源且支持自部署。
可以使用JetBrain 的TeamCity 构建软件开发、容器化部署流程。
https://docs.xin-lai.com/2019/03/05/容器教程/Docker最全教程之使用TeamCity来完成内部CI、CD流程(十六)/
sudo docker-compose up -d --build
sudo docker exec -it nginx /bin/sh
删除容器
<aside> 📖 docker.io 是旧版本:卸载
</aside>
卸载旧版本
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
还要删除CLIhttps://docs.docker.com/engine/install/debian/#uninstall-docker-engine
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
脚本安装docker
apt
安装
Debian:https://docs.docker.com/engine/install/debian/
添加Docker’s apt repository
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL <https://download.docker.com/linux/debian/gpg> -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \\
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] <https://download.docker.com/linux/debian> \\
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \\
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
install docker plugins
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
verify:
sudo docker run hello-world
启动
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
sudo docker ps
docker context create rootful --docker "host=unix:///var/run/docker.sock"
docker context use rootful
容器内可以使用NVIDA显卡和CUDA、
Prepare:一般Docker已经集成了NVIDIA Container Toolkit(WSL也是),https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html| 验证手段是运行nvidia-smi
命令行
WSL-> nvidia-smi
WSL-> sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi
PS-> docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi
Docker-compose
启用NVIDAI Container Toolkit后,可以在yaml文件中声明GPU使用和分配
app:
build:
context: ..
dockerfile: .devcontainer\\Dockerfile
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
environment:
- NVIDIA_VISIBLE_DEVICES=all
CUDA
NVIDIA有针对vscode开发容器的feature
{
"features": {
"ghcr.io/devcontainers/features/cuda:12.6": {}
}
}
手动添加runfile,选择只安装toolkit
# 安装CUDA
RUN --mount=type=bind,source="docker/cuda_12.6.0_560.28.03_linux.run",target=/tmp/cuda.run \\
sh /tmp/cuda.run --silent --toolkit --toolkitpath=/usr/local/my-paddle/cuda-12.6 \\
&& rm -rf /var/cuda-installer*
# 设置环境变量
ENV PATH=/usr/local/my-paddle/cuda-12.6/bin:$PATH
ENV LD_LIBRARY_PATH=/usr/local/my-paddle/cuda-12.6/lib64:$LD_LIBRARY_PATH
CuDNN