docker无法使用vim_Docker环境下Redmine的部署指南

# 1、启动mysql镜像

docker run -d -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD="secret" -e MYSQL_DATABASE=redmine mysql:5.7

如果本地仓库没有MySQL镜像,docker将自动拉去官方仓库拉去,如下图:

a563ecf7454dc6e1afdbc475754fb882.png

# 2、 修改mysql配置(主要修改utf-8字符集)

参考资料:http://blog.csdn.net/sqandczm/article/details/78152451?locationNum=7&fps=1

docker exec -it cee6 /bin/bash # 进入容器
mysql -u root -p # 登录数据库,密码:secset
5c0e7cfe1dca56c09a0e3da042dcbf50.png
SHOW VARIABLES LIKE 'character_set_%'; # 查看数据库字符集
SHOW VARIABLES LIKE 'collation_%';
SET NAMES 'utf8';
276a2db71529b34daa1ffb27eb2075c8.png

最后修改/etc/mysql/mysql.conf.d/mysql.cnf配置文件,内容如下所示(黄底字体部分):

~~~bash

# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.

#

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by

# the Free Software Foundation; version 2 of the License.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#

# The MySQL Server configuration file.

#

# For explanations see

# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysql]

default-character-set = utf8

[mysql_safe]

default-character-set = utf8

[client]

default-character-set = utf8

[mysqld]

pid-file = /var/run/mysqld/mysqld.pid

socket = /var/run/mysqld/mysqld.sock

datadir = /var/lib/mysql

#log-error = /var/log/mysql/error.log

# By default we only accept connections from localhost

#bind-address = 127.0.0.1

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

init_connect = 'SET NAMES utf8'

character-set-server = utf8

collation-server = utf8_unicode_ci

~~~

exit退出数据库

vim /etc/mysql/mysql.conf.d/mysqld.cnf 报错,

2b8c6197b2d682ca29c98958e02143b8.png

因为镜像中没有安装vim,所以需要安装vim

通过查看官方dockerfile文件得知mysql官方镜像的基础镜像是debian ,所以安装vim的命令是:

Apt-get install -y vim

接着会报错 E: Unable to locate package vim

fd8e86ab60f9ababd9e3861783cbdd13.png

究其原因,应该是镜像刚运行,软件源还来不及更新,所以才会无法找到包。

这时候需要敲:apt-get update

这个命令的作用是:同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,这样才能获取到最新的软件包。

73ac799af90fce9833a8b614fd289065.png

等更新完毕以后再敲命令:apt-get install -y vim命令即可,现在可以使用vim了。

vim /etc/mysql/mysql.conf.d/mysqld.cnf
97d6adfa3d759a4ae8a6cba8fbff8a40.png

保存退出后,exit退出容器,docker restart 重启容器

68cb6e1238ae54cce73f403e2423776b.png

**注:修改配置文件后退出并重启mysql服务(通过docker restart命令);另本步骤为必须,否则redmine将无法正确保存中文,会报异常无法操作。**

完成MySQL配置后,将容器打包成新的镜像,以后再部署redmine的MySQL服务器就可以直接使用新镜像了

docker commit cee mysql-with-vim
c1a2d324b54bed38a9a5ec12ef628f69.png

# 3、 docker下拉取并启动redmine镜像

docker run -d -p 8088:3000 --name some-redmine --link some-mysql:mysql redmine:3.4
95755f9d3547f57b829743bf741a189a.png

# 4、 访问Redmine打开浏览器访问物理机的8088端口就可以打开redmine的页面了。管理员帐号是admin,密码admin

77c7b922c2cecb5cb6eaf3548da7b7fa.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值