Docker-compose部署chemexIT资产管理系统堆栈
一、安装Docker
- 部署docker的yum源
cat > /etc/yum.repos.d/docker-ce.repo <<EOF
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/centos/$releasever/source/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://download.docker.com/linux/centos/$releasever/source/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://download.docker.com/linux/centos/$releasever/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
EOF
yum clean
yum makecache
- yum安装docker
yum -y install docker-ce
二、安装docker-compose
- 下载二进制文件
cd /usr/src/
wget https://github.com/docker/compose/releases/download/1.24.0/docker-compose-Linux-x86_64
- 移动文件到/usr/local/bin下
mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
- 赋予可执行权限
chmod +x /usr/local/bin/docker-compose
- 创建软链接
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
- 测试
docker-compose --version
- 启动docker
systemctl enable docker --now
三、拉取所需要的镜像
- 拉取mysql镜像
docker pull mysql:8.0
- 拉取chemex镜像
docker pull celaraze/chemex:latest
四、编写docker-compose.yml部署chemex
- 创建存放的父目录
mkdir -p /home/chemex-server
- 创建mysql映射的目录
/home/chemex-server/mysql/data
#存放mysql的数据
/home/chemex-server/mysql/log#存放mysql的日志
cd /home/chemex-server
mkdir -p mysql/data
mkdir -p mysql/log
- 编写docker-compose部署文件(使用的yml格式)
cd /home/chemex-server
vim docker-compose.yml
---
version: "3"
services:
mysql:
container_name: mysql
command: "--max_connections=1000 --wait_timeout=28800 --interactive_timeout=28800 --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci"
environment:
- MYSQL_ROOT_PASSWORD=myrootpasswd
- MYSQL_DATABASE=chemex
- MYSQL_USER=chemex
- MYSQL_PASSWORD=mypasswd
- TZ=Asia/Shanghai
expose:
- "3306"
image: "mysql:8.0"
networks:
- chemex-net
restart: always
privileged: true
volumes:
- "./mysql/data:/var/lib/mysql"
- "./mysql/log:/var/log/mysql"
chemex:
container_name: chemex
links:
- chemex-mysql
environment:
- DB_HOST=mysql
- DB_PORT=3306
- DB_DATABASE=chemex
- DB_USERNAME=chemex
- DB_PASSWORD=mypasswd
- INSTALL=true
image: "celaraze/chemex:latest"
networks:
- chemex-net
ports:
- "9876:80" #9876修改成可以访问的端口号
restart: always
privileged: true
networks:
chemex-net:
driver: bridge
ipam:
config:
- subnet: 192.168.1.0/24
gateway: 192.168.1.1
- 启动docker-compose
docker-compose up -d
- 查看启动状态
docker-compose ps
- 查看容器启动日志
docker-compose log
五、浏览器访问
- 浏览器访问http://ip:9876
- 用户名admin,初始密码admin