安装docker

  • 参考美团云的一个教程–在CentOS上安装Docker
    • 如果遇到启动服务时提示

WARN[0000] You are running linux kernel version 2.6.32-431.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
docker: relocation error: docker: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference

参考[这个文章](http://collabnix.com/archives/1012)

yum-config-manager –enable public_ol6_latest
yum install device-mapper-event-libs

添加阿里云docker镜像加速器

sudo vim /etc/sysconfig/docker
// other_args=”–registry-mirror=”
sudo service docker restart
sudo ps -ef | grep docker

配置redmine&mysql

  • 镜像选择

    • 官方的redmine镜像可配置项较少,选择使用sameersbn/redmine
  • 拉取镜像

sudo docker pull sameersbn/redmine:3.3.2-1
sudo docker pull mysql:5.7.18

  • 建立数据目录

mkdir -p /where/ever/you/like/mysql
mkdir -p /where/ever/you/like/mysql-conf
mkdir -p /where/ever/you/like/redmine-data

  • 安装docker-compose
    • 因为只安装了1.7.1版的docker,所以不能使用高版本的compose,只能用1.5.2配合version 1的yml文件使用

curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-uname -suname -m > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

  • 修改compose配置
    • 获取基础模板

wget https://raw.githubusercontent.com/sameersbn/docker-redmine/master/docker-compose.yml

  • 修改配置。注意设定密码。此处直接使用ROOT用户给redmine使用。

    另外,使用QQ企业邮箱发送邮件,端口要使用25,SMTP_USER要和之后redmine设置面板中的发件人保持一致,否则会报501错误。

    在映射的/mnt/redmine/mysql-conf路径下添加xxx.cnf配置文件,保证mysql使用utf8mb4_unicode_ci

mysql.cnf

[mysqld]
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
skip-character-set-client-handshake

[client]
default-character-set   = utf8

[mysql]
default-character-set   = utf8

docker-compose.yml

  mysql:
    image: mysql:5.7.18
    environment:
    - MYSQL_ROOT_PASSWORD=xxx
    - MYSQL_DATABASE=redmine-production
    volumes:
    -  /where/ever/you/like/mysql:/var/lib/mysql
    -  /where/ever/you/like/mysql-conf:/etc/mysql/conf.d

  redmine:
    image: sameersbn/redmine:3.3.2-1
    links:
    - mysql
    environment:
    - TZ=Asia/Shanghai

    - DB_ADAPTER=mysql2
    - DB_HOST=mysql
    - DB_PORT=3306
    - DB_USER=root
    - DB_PASS=xxx
    - DB_NAME=redmine_production

    - REDMINE_PORT=10083
    - REDMINE_HTTPS=false
    - REDMINE_RELATIVE_URL_ROOT=
    - REDMINE_SECRET_TOKEN=

    - REDMINE_SUDO_MODE_ENABLED=false
    - REDMINE_SUDO_MODE_TIMEOUT=15

    - REDMINE_CONCURRENT_UPLOADS=2

    - REDMINE_BACKUP_SCHEDULE=
    - REDMINE_BACKUP_EXPIRY=
    - REDMINE_BACKUP_TIME=

    - SMTP_ENABLED=true
    - SMTP_METHOD=smtp
    - SMTP_DOMAIN=exmail.qq.com
    - SMTP_HOST=smtp.exmail.qq.com
    - SMTP_PORT=25
    - SMTP_USER=xxx@xxxxxx.com
    - SMTP_PASS=xxxxx
    - SMTP_STARTTLS=true
    - SMTP_AUTHENTICATION=:login

    ports:
    - "9124:80"
    volumes:
    -  /where/ever/you/like/redmine-data:/home/redmine/data

  • 启动docker container

docker-compose up //会自动根据配置更新container

  • iptables配置

    • 如果默认的FORWARD规则是DROP的话,需要添加

iptables -A FORWARD -i docker0 -j ACCEPT

  • 查看iptables nat

sudo iptables -t nat -L -n

  • 查看当前iptables规则

sudo less /etc/sysconfig/iptables

  • 如果重启iptables的话会导致docker无法启动容器
    • iptables: No chain/target/match by that name.

sudo service docker restart

  • 配置nginx转发请求
    • sameersbn/redmine镜像中已带nginx,可以直接映射出80端口使用,也可以再转接一层

其他参考

  • Docker — 从入门到实践
  • Iptables (简体中文)
  • docker-mysql

文章来源于互联网,如有雷同请联系站长删除:CentOS 6.5上安装docker & redmine

发表评论