centos7 firewalld ip转发设置、安装docker-compose出现错误、docker-compose部署Yapi

一 centos7 firewalld ip转发设置

#!/bin/bash
#开启系统路由模式功能
vim /etc/sysctl.conf
#添加下面一行
net.ipv4.ip_forward=1
#运行这个命令会输出上面添加的那一行信息,意思是使内核修改生效
sysctl -p
#开启firewalld
systemctl start firewalld
#防火墙开启4444端口
firewall-cmd --zone=public --add-port=4444/tcp --permanent
#设置IP地址伪装
firewall-cmd --add-masquerade --permanent
#设置端口映射
firewall-cmd --add-forward-port=port=4444:proto=tcp:toaddr={ip}:toport=4444 --permanent
firewall-cmd --add-masquerade --permanent
#重启firewall
firewall-cmd --reload


-------------------------------------------------------------------------
firewall相关命令:
查看所有规则:firewall-cmd --list-all
添加端口:firewall-cmd --add-port=80/tcp --permanent
移除端口:firewall-cmd --remove-port=80/tcp --permanent
删除转发策略:firewall-cmd --remove-forward-port=port=4444:proto=tcp:toaddr={ip}:toport=4444 --zone=public --permanent
查看端口状态:firewall-cmd --zone=public --query-port=80/tcp
重启:firewall-cmd --reload

二 安装docker-compose出现错误html: No such file or directory syntax error near unexpected token `<‘ <head><t

安装docker-compose出现
/usr/local/bin/docker-compose: line 1: html: No such file or directory
/usr/local/bin/docker-compose: line 2: syntax error near unexpected token <' 'usr/local/bin/docker-compose: line 2:
错误

---------------------------------------------------------------------
解决
重新安装docker-compose,国内的有些快捷方式有些是有问题的,
可能短期内能够使用,时间长了就会出现问题
尽量直接使用GitHub的,如果一次下载不成,多执行几遍就可以

curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 


没有权限记得加sudo
 chmod +x /usr/local/bin/docker-compose
 
 docker-compose -v


三 docker-compose部署Yapi

1.安装docker

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 install docker-ce
systemctl start docker  # 启动docker服务

2 安装docker-compose

curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

3 新建docker-compose.yml

vim docker-compose.yml

version: '3'

services:
  yapi-web:
    image: liuqingzheng/yapi:latest
    container_name: yapi-web
    ports:
      - 3000:3000
    environment:
      - YAPI_ADMIN_ACCOUNT=306334678@qq.com
      - YAPI_ADMIN_PASSWORD=admin
      - YAPI_CLOSE_REGISTER=true
      - YAPI_DB_SERVERNAME=yapi-mongo
      - YAPI_DB_PORT=27017
      - YAPI_DB_DATABASE=yapi
      - YAPI_MAIL_ENABLE=false
      - YAPI_LDAP_LOGIN_ENABLE=false
      - YAPI_PLUGINS=[]
    depends_on:
      - yapi-mongo
    links:
      - yapi-mongo
    restart: unless-stopped
  yapi-mongo:
    image: mongo:latest
    container_name: yapi-mongo
    volumes:
      - ./data/db:/data/db
    expose:
      - 27017
    restart: unless-stopped

4 启动

docker-compose up -d # 启动
docker-compose stop  # 停止
docker-compose rm    # 删除

5 访问

http://127.0.0.1:3000/
输入邮箱:306334678@qq.com
输入密码:admin

你可能感兴趣的:(Linux,tcp/ip,docker,yapi)