[+] docker init

This commit is contained in:
Martin 2025-01-04 15:49:08 +08:00
parent e72be89dc7
commit 7df7a0c0e0
3 changed files with 50 additions and 4 deletions

View File

@ -1,3 +1,20 @@
#### 安装
```bash
# apt + ntp
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-apt.sh | bash
# docker-ce
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-docker.sh | bash
# 初始化全部
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-all.sh | bash
```
#### 进入容器
```bash
docker compose run debian bash
@ -13,10 +30,7 @@ docker compose run debian ./init-apt.sh
```bash
docker compose run ubuntu ./init-apt.sh
```
##### 直接运行
```bash
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-apt.sh | bash
```
##### docker 容器中
```bash
RUN --mount=type=cache,target=/var/cache/apt \

6
init-all.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
# apt + ntp
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-apt.sh | bash
# docker-ce
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-docker.sh | bash

26
init-docker.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
command_exists() {
command -v "$@" > /dev/null 2>&1
}
if command_exists docker; then
cat >&2 <<-'EOF'
docker 已安装.... 跳过
EOF
( set -x; sleep 20 )
else
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/docker-install.sh | sh
fi
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://docker.martin98.com",
"https://registry-docker.martin98.com",
"https://registry-dockerhub.hk.martin98.com"
]
}
EOF
sudo systemctl restart docker