独书先生 Menu

Viewing all items for tag mysql

windows docker 部署gogs / mysql / yapi / mongo

windows docker 部署gogs / mysql / yapi / mongo

environment

  1. docker for windows desktop
  2. docker configuration
{
  "registry-mirrors": [
    "http://hub-mirror.c.163.com",
    "https://registry.docker-cn.com"
  ],
  "insecure-registries": [],
  "debug": true,
  "experimental": false
}

gogs and mysql service

gogs and mysql network

docker network create --subnet 172.21.0.0/16 gogs_network

mysql

docker run --name my-mysql -p 3306:3306 -v C:/software/mysql:/var/lib/mysql --net gogs_network --ip 172.21.0.3 -e MYSQL_DATABASE=gogsdb -e MYSQL_USER=gogsuser -e MYSQL_PASSWORD=gogspwd -e MYSQL_ROOT_PASSWORD=gogspwd -e MYSQL_ALLOW_EMPTY_PASSWORD='yes' -d mysql

gogs

docker run --name my-gogs -p 1001:22 -p 1002:3000 -v C:/software/gogs/data:/data --net gogs_network --ip 172.21.0.2 gogs/gogs

yapi and mongo service

yapi and mongo network

docker network create --subnet 172.22.0.0/16 yapi_network

start mongo

docker volume create --name mongodata
docker volume create --name mongoconfigdb

docker run --name my-mongo -p 27017:27017 -v mongodata:/data/db -v mongoconfigdb:/data/configdb --net yapi_network --ip 172.22.0.3 -d mongo:4 --auth

mongo setting

# into mongo container
docker exec -it my-mongo mongo admin

# set admin user (root)
db.createUser({ user: 'admin', pwd: 'admin123456', roles: [ { role: "root", db: "admin" } ] });

# auth admin user
db.auth("admin", "admin123456")

# restart mongo
docker restart my-mongo

# into mongo container again
docker exec -it my-mongo mongo -u admin -p admin123456 --authenticationDatabase admin

# create yapi database
use yapi

# set yapi user
db.createUser({ 
    user: 'yapi', 
    pwd: 'yapi123456', 
    roles: [
        { role: "dbAdmin", db: "yapi" },
        { role: "readWrite", db: "yapi" } 
    ]
});

# auth yapi user
db.auth("yapi", "yapi123456")

yapi

docker build -t yapi .
docker run --name my-yapi -p 1003:3000 -p 1004:9090 -v C:/software/yapi/my-yapi:/my-yapi --net yapi_network --ip 172.22.0.2 -d yapi sh -c "yapi server"

deploy

open http://localhost:1004/ to deploy,get account:”admin@admin.com”, password:”ymfe.org”

change command restart serve

docker stop my-yapi
docker rm my-yapi
docker run --name my-yapi -p 1003:3000 -p 1004:9090 -v C:/software/yapi/my-yapi:/my-yapi --net yapi_network --ip 172.22.0.2 -d yapi sh -c "node my-yapi/vendors/server/app.js"

open http://localhost:1003/ to use

refer

https://hub.docker.com/_/mongo
https://www.cnblogs.com/woshimrf/p/docker-install-yapi.html
https://github.com/Ryan-Miao/docker-yapi
https://www.cnblogs.com/lori/p/7897003.html
https://segmentfault.com/q/1010000006128749