安裝docker
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce -y
sudo systemctl enable docker
sudo systemctl start docker
安裝docker-compose
pip install docker-compose -i https://mirrors.aliyun.com/pypi/simple/
如果pip不存在,可以嘗試
sudo yum install python-pip
sudo pip install --upgrade pip
vim docker-compose.yml
# docker version: 18.06.0+
# docker-compose version: 1.23.2+
# OpenSSL version: OpenSSL 1.1.0h
version: "3.7"
services:
web:
image: alenx/walle-web:2.1
container_name: walle-nginx
hostname: nginx-web
ports:
# 如果宿主機80埠被佔用,可自行修改為其他port(>=1024)
# 0.0.0.0:要繫結的宿主機埠:docker容器內埠80
- "80:80"
depends_on:
- python
networks:
- walle-net
restart: always
python:
image: alenx/walle-python:2.1
container_name: walle-python
hostname: walle-python
env_file:
# walle.env需和docker-compose在同級目錄
- ./walle.env
command: bash -c "cd /opt/walle_home/ && /bin/bash admin.sh migration && python waller.py"
expose:
- "5000"
volumes:
- /opt/walle_home/plugins/:/opt/walle_home/plugins/
- /opt/walle_home/codebase/:/opt/walle_home/codebase/
- /opt/walle_home/logs/:/opt/walle_home/logs/
- /root/.ssh:/root/.ssh/
depends_on:
- db
networks:
- walle-net
restart: always
db:
image: mysql
container_name: walle-mysql
hostname: walle-mysql
env_file:
- ./walle.env
command: [ '--default-authentication-plugin=mysql_native_password', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
ports:
- "3306:3306"
expose:
- "3306"
volumes:
- /data/walle/mysql:/var/lib/mysql
networks:
- walle-net
restart: always
networks:
walle-net:
driver: bridge
vim walle.env
# Set MySQL/Rails environment
MYSQL_USER=root
MYSQL_PASSWORD=walle
MYSQL_DATABASE=walle
MYSQL_ROOT_PASSWORD=walle
MYSQL_HOST=db
MYSQL_PORT=3306
docker-compose up -d && docker-compose logs -f
# 開啟瀏覽器localhost:80
登入帳號
超管:super@walle-web.io \ Walle123
所有者:owner@walle-web.io \ Walle123
負責人:master@walle-web.io \ Walle123
開發者:developer@walle-web.io \ Walle123
訪客:reporter@walle-web.io \ Walle123
docker管理
# 構建服務
docker-compose build
# 啟動服務,啟動過程中可以直接檢視終端日誌,觀察啟動是否成功
docker-compose up
# 啟動服務在後臺,如果確認部署成功,則可以使用此命令,將應用跑在後臺,作用類似 nohup python waller.py &
docker-compose up -d
# 檢視日誌,效果類似 tail -f waller.log
docker-compose logs -f
# 停止服務,會停止服務的執行,但是不會刪除服務所所依附的網路,以及儲存等
docker-compose stop
# 刪除服務,並刪除服務產生的網路,儲存等,並且會關閉服務的守護
docker-compose down
本作品採用《CC 協議》,轉載必須註明作者和本文連結