1、安装docker、docker-compose
#升级yum
sudo yum update
#卸载旧版本docker
sudo yum remove docker docker-common docker-selinux docker-engine
#安装依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
#设置源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
#安装docker
sudo yum install docker-ce
#启动服务
sudo systemctl start docker
#查看版本
docker version
#拉取镜像
docker pull hello-world
#启动容器
docker run hello-world
#如果出现下面的输入则表示安装成功
'''
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
'''
#安装docker-compose,并授权
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
#安装成功后,检查版本号
docker-compose -v
2、安装YApi
#首先,在GitHub上面克隆项目,执行一条就行
git clone https://github.com/fjc0k/docker-YApi.git
#无法访问github的可使用国内替代:
git clone https://gitee.com/fjc0k/docker-YApi.git
#接下来要修改下载下来的项目中,修改docker-compose.yml中yapi-web下的环境变量YAPI_ADMIN_ACCOUNT为你的管理员邮箱,YAPI_ADMIN_PASSWORD为你的管理员密码。
#YAPI_CLOSE_REGISTER为是否关闭注册默认叔true,我们改成false就可以注册新用户了
最后,执行docker-compose up -d启动服务。
然后,通过http://localhost:40001即可访问YApi。