docker
1.docker 国内访问下载速度太慢, 借用第三方 DaoCloud
提供的 docker 安装源
curl -sSL https://get.daocloud.io/docker | sh
2. 安装完成后, 使用 docker info
查看 docker 状态, 但是需要使用 sudo 权限, 因为 docker 命令属于 docker 用户组, 为了避免每次输入命令需要带 sudo, 可将当前用户加入 docker 组
sudo gpasswd -a $(whoami) docker
3. 配置镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://**.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
docker-compose
1.docker-compose 存放在 github 上, 安装速度不太理想, 还是借用 DaoCloud
提供的 docker-compose 安装源
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
2. 常用 docker-compose
.env
:
DCOMPOSE_DIR=/data/dcompose
MYSQL_ROOT_PASSWORD=123456
docker-compose.yml
:(自动加载同目录下的.env)
version: "3"
services:
mysql:
image: mysql:5.7
container_name: mysql
restart: on-failure:3
environment:
# 环境变量
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
volumes:
- "${DCOMPOSE_DIR}/mysql/data:/var/lib/mysql"
- "${DCOMPOSE_DIR}/mysql/conf.d:/etc/mysql/conf.d"
ports:
- 3306:3306
tengine:
image: axizdkr/tengine:2.3.2
container_name: tengine
restart: on-failure:3
environment:
- TZ=Asia/Shanghai
- LANG=zh_CN.UTF-8
ports:
- "80:80"
- "443:443"
volumes:
- ${DCOMPOSE_DIR}/tengine/conf.d/:/etc/nginx/conf.d/
- ${DCOMPOSE_DIR}/tengine/log/:/var/log/nginx/