Files
shellscripts/docker/README.md
Your Name 14728853aa update
2025-01-23 00:08:45 +08:00

77 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## install docker
使用官方源安装(国内直接访问较慢)
curl -fsSL https://get.docker.com | bash
使用阿里源安装
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
使用中国区Azure源安装
curl -fsSL https://get.docker.com | bash -s docker --mirror AzureChinaCloud
自启动Docker
systemctl enable --now docker
一键安装最新版Docker Compose
```shell
COMPOSE_VERSION=`git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9][0-9]+\.[0-9]+$" | sort --version-sort | tail -n 1`
sh -c "curl -L https://github.com/docker/compose/releases/download/v${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
chmod +x /usr/local/bin/docker-compose
```
## nvidia-docker
sudo chown -R root:docker /data/docker
sudo chmod -R 770 /data/docker
```shell
sudo apt-get update
sudo apt-get install -y curl gnupg lsb-release
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
echo "NVIDIA Docker 已安装。"
```
## 更改镜像目录
vim /etc/docker/daemon.json
{
"data-root": "/data/docker"
}
## 换源
https://www.kelen.cc/dry/docker-hub-mirror
添加换源的mirror
```json
{
"data-root": "/data/docker",
"features": {
"buildkit": true
},
"registry-mirrors": [
"https://hub.rat.dev",
"https://dockerhub.icu",
"https://docker.unsee.tech"
],
"runtimes": {
"nvidia": {
"args": [],
"path": "nvidia-container-runtime"
}
}
}
```