開發中常常須要快速部署一臺隨用隨關的數據庫服務器,如mysql,oracle,mongodb,elastic-searchnode
一直以爲docker特別方便,加上docker-compose.yaml簡直如虎添翼mysql
新建目錄並選擇須要的服務器,寫入docker-compose.yaml,執行docker-compose up -d
便可。
ps1. 如須要,請自行依據對應鏡像主頁說明,修改鏡像版本和密碼等參數
ps2. 若是不能啓動,請嘗試sudo chmod 774 data/修改目錄權限sql
version: '2' services: mysql_db: restart: always image: mysql:8 command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci environment: MYSQL_ROOT_PASSWORD: root123456 ports: - 127.0.0.1:3306:3306 volumes: - ./data:/var/lib/mysql
version: '2' # https://hub.docker.com/r/datagrip/oracle # username: system # password: oracle services: oracle_db: restart: always image: sath89/oracle-xe-11g ports: - 127.0.0.1:1521:1521 volumes: - ./data:/u01/app/oracle
mongo_master: restart: always image: mongo:4.0 ports: - 127.0.0.1:27017:27017 volumes: - ./data:/data/db
elasticsearch_master: restart: always image: elasticsearch:7.1.0 hostname: elasticsearch environment: discovery.type: single-node ports: - 127.0.0.1:9200:9200 volumes: - ./data:/usr/share/elasticsearch/data