XWiki開發指南0-使用docker安裝XWiki

參考docker-xwiki項目的README,Using docker-compose一節使用docker-compose安裝docker,這種方法異常簡單幾乎是一鍵安裝。
我們需要三個文件如下

xwiki.cnf #xwiki的配置文件
init.sql #數據庫初始化文件
docker-compose.yml #docker-compose文件

README裏邊的文件下載地址有點問題,文件下載不了,但是我發現其實需要的文件都在docker-xwiki項目裏邊,所以只要克隆docker-xwiki項目到本地就可以了。
然後把xwiki工作目錄/docker-xwiki-master/11/mysql-tomcat/mysql下的兩個文件拷貝到你的工作目錄下,再把xwiki工作目錄/docker-xwiki-master/docker-compose-mysql.yml拷貝到你的工作目錄並且重命名爲docker-compose.yml。然後進入你的工作目錄執行

docker-compose up -d#-d參數會讓容器在後臺運行

執行完成如果沒有發生錯誤會爲你啓動兩個容器,一個是XWiki容器,一個是MySQL容器。
使用docker ps查看

CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                    NAMES
36a445777132        xwiki:lts-mysql-tomcat   "docker-entrypoint.s…"   31 minutes ago      Up 28 minutes       0.0.0.0:8080->8080/tcp   xwiki-mysql-tomcat-web
50c68c806a34        mysql:5.7                "docker-entrypoint.s…"   31 minutes ago      Up 28 minutes       3306/tcp, 33060/tcp      xwiki-mysql-db

這時可以訪問XWiki了,打開localhost:8080
如果看到如下信息則代表XWiki安裝成功了。
在這裏插入圖片描述

更換XWiki鏡像

docker-compose.yml裏邊的XWiki鏡像是lts-mysql-tomcat不是很新,我們可以使用stable-mysql-tomcat來替換。替換之後的內容如下:

version: '2'
networks:
  bridge:
    driver: bridge
services:
  web:
    # Use an already built XWiki image from DockerHub.
    image: "xwiki:stable-mysql-tomcat"#使用更新的鏡像
    container_name: xwiki-mysql-tomcat-web
    depends_on:
      - db
    ports:
      - "8080:8080"
    # The DB_USER/DB_PASSWORD/DB_HOST variables are used in the hibernate.cfg.xml file.
    environment:
      - DB_USER=xwiki
      - DB_PASSWORD=xwiki
      - DB_DATABASE=xwiki
      - DB_HOST=xwiki-mysql-db
    # Provide a name instead of an auto-generated id for the xwiki permanent directory configured in the Dockerfile,
    # to make it simpler to identify in 'docker volume ls'.
    volumes:
      - xwiki-data:/usr/local/xwiki
    networks:
      - bridge
  # The container that runs MySQL
  db:
    image: "mysql:5.7"
    container_name: xwiki-mysql-db
    # - We provide a xwiki.cnf file in order to configure the mysql db to support UTF8 and be case-insensitive
    # We have to do it here since we use an existing image and that's how this image allows customizations.
    # See https://hub.docker.com/_/mysql/ for more details.
    # - Provide a name instead of an auto-generated id for the mysql data, to make it simpler to identify in
    # 'docker volume ls'
    volumes:
      - ./xwiki.cnf:/etc/mysql/conf.d/xwiki.cnf
      - mysql-data:/var/lib/mysql
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    # Configure the MySQL database and create a user with provided name/password.
    # See https://hub.docker.com/_/mysql/ for more details.
    environment:
      - MYSQL_ROOT_PASSWORD=xwiki
      - MYSQL_USER=xwiki
      - MYSQL_PASSWORD=xwiki
      - MYSQL_DATABASE=xwiki
    networks:
      - bridge
volumes:
  mysql-data: {}
  xwiki-data: {}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章