美文网首页
2017-11-22 创建Docker build

2017-11-22 创建Docker build

作者: Janny_lwj | 来源:发表于2017-11-22 16:44 被阅读0次

安装mysql:

1.安装:

sudo yum install mysql-server

2.改密码:

获取密码 grep "password" /var/log/mysqld.log

使用mysqladmin 修改密码 mysqladmin -u root -p oldpasswd -password newpasswd

3.由于在公司需要改端口

http://blog.itpub.net/26148431/viewspace-1466379/

4.权限问题

a.Mysql -u root -p

b.Grant all privileges on *.* to ‘user’@’%’identified by ‘password’;

c.Flush privileges;

d.Service mysql restart

5.防火墙:

a.先添加配置 firewall-cmd --add-port=/tcp --permanent

b.reload使配置生效 firewall-cmd --reload

Docker:

1.安装docker:

安装:sudo yum install docker

2.启进程:systemctl start docker 

3.创建Dockerfile文件Vi Dockerfilea.准备dockerfile

4.上传文件到服务器:

a.允许scp上传文件 Yum install openssh-server

b.Windows端:git bash: scp restmanagement.xip root@host:/home

c.解压文件:unzip zipfile(first should: yum install -y unzip)

5.制作镜像

a.启动docker:systemctl start docker

b.Docker build -t.

c.Docker run -p:80 -t -i

6.Docker run server successfully,Web access denied. 

7.出错debug

a.配置http服务器:Down httpd.conf

scp root@198.13.35.165:/home/temp/httpd.conf httpd.conf

scp httpd.conf root@198.13.35.165:/home/temp/httpd.conf 

add below code in httpd.conf:

see github

b.看Log cd /etc/conf/logs

c.Wsgi.py load error/can’t find project/settings: 

Add below code in wsgi.py file

sys.path.append(r'/etc/www/html/restmanage-tool')

sys.path.append(r'/etc/www/html/restmanage-tool/restmanagement')

8.备份dockerfile

a.Download Dockerfile from server

b.Upload Dockerfile to git 

Git command:

Git clone

Git add

Git commit -m <‘version name’>

Git push

9. 数据库dump

备份数据:

mysqldump --add-drop-table --triggers --routines -c -u Janny -h10.71.2.138 -pJanny123! janny > janny.backup.sql

恢复数据:

mysql -u janny -p janny < janny.backup.sql

10. 自动调用apachectl:

在dockerfile相同的文件夹下面,创建file: run.sh,内容如下:

#!/bin/bash

/sbin/sshd &

/sbin/httpd -D FOREGROUND

Add below content in Dockerfile:

#启动apache服务

RUN /sbin/httpd

#复制服务启动脚本并设置权限

ADD run.sh /usr/local/sbin/run.sh

RUN chmod 755 /usr/local/sbin/run.sh

#开放80端口

EXPOSE 80

CMD ["/sbin/run.sh"]

相关文章

网友评论

      本文标题:2017-11-22 创建Docker build

      本文链接:https://www.haomeiwen.com/subject/ghcovxtx.html