Ubuntu下安裝Dockerlinux
version: "3.3" services: mongodb: image: mongo:5.0 volumes: - type: bind source: /home/yourname/data/mongodb/easymock # 數據庫文件存放地址,根據須要修改成本地地址 target: /data/db redis: image: redis:4.0.6 command: redis-server --appendonly yes volumes: - type: bind source: /home/yourname/data/redis/easymock # redis 數據文件存放地址,根據須要修改成本地地址 target: /data web: image: easymock/easymock:1.6.0 command: /bin/bash -c "npm start" links: - mongodb:mongodb ports: - 7300:7300 volumes: - type: bind source: /home/yourname/easy-mock/logs # 日誌地址,根據須要修改成本地地址 target: /home/easy-mock/easy-mock/logs - type: bind source: /home/yourname/easy-mock/config/local.json # 配置地址,請使用本地配置地址替換 target: /home/easy-mock/easy-mock/config/production.json
去掉"db"和"redis"配置redis
{ "port": 7300, "host": "0.0.0.0", "pageSize": 30, "proxy": false, "unsplashClientId": "", "blackList": { "projects": [], "ips": [] }, "rateLimit": { "max": 1000, "duration": 1000 }, "jwt": { "expire": "14 days", "secret": "shared-secret" }, "upload": { "types": [ ".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml" ], "size": 5242880, "dir": "../public/upload", "expire": { "types": [ ".json", ".yml", ".yaml" ], "day": -1 } }, "fe": { "copyright": "", "storageNamespace": "easy-mock_", "timeout": 25000, "publicPath": "/dist/" } }
docker-compose up -d
。sudo docker ps
查看是否已運行若是easy-mock的端口設置爲7300,到阿里雲服務器管理列表中,添加安全規則,採用"tcp",端口號設爲"7300/7300",其餘按照教程設置。mongodb
在網頁上輸入IP:7300
便可訪問easy-mockdocker
Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?數據庫
答案:須要將當前用戶加入到docker用戶組
sudo gpasswd -a ${USER} docker
npm
網上教程json
答案:須要建立「/data/mongodb/easymock」等路徑。ubuntu