2018-01-03 第一个Docker部署

安装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’@’%’identifiedby ‘password’;

c.     Flush privileges;

d.    Service mysql restart

5.     防火墙:

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

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


Docker:

1.   安装docker:

安装:sudoyum install docker

2.    启进程:systemctl start docker

3.    创建Dockerfile文件

Vi Dockerfile

a.     准备dockerfile

4.      上传文件到服务器:

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

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

c.      解压文件:unzip zipfile(first should: yuminstall -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

scproot@198.13.35.165:/home/temp/httpd.confhttpd.conf

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


addbelow code in httpd.conf:

LoadModule wsgi_modulemodules/mod_wsgi.so

WSGIScriptAlias //var/www/html/restmanage-tool/restmanagement/restmanagement/wsgi.py

Alias /static//var/www/html/restmanage-tool/restmanagement/static/

ServerName198.13.35.165

DocumentRoot/var/www/html/

Order allow,deny

Allow from all

Order allow,deny

Allow from all


ErrorLog/etc/httpd/logs/restmanagement.log

Loglevel warn

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 <‘versionname’>

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


Addbelow 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"]

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 安装mysql: 1.安装: sudo yum install mysql-server 2.改密码: 获取密码 ...
    Janny_lwj阅读 186评论 0 0
  • 基于Docker的Django-Mysql-Apache应用容器化 2017-05-25 Mysql的容器 Dja...
    邱simple阅读 2,655评论 0 5
  • 一直有一种想写文章的感觉,以前总爱看些小说,特别容易沉迷其中废寝忘食到荒废学业,不过那都是在以前上学的时候不爱学习...
  • 今天不算的是满意的一天,洗衣机总是洗洗停停,一大早扔进去的衣服到中午才洗完。再到中午给猫洗澡,以往都很乖的,今天被...
    喵花阅读 265评论 0 1
  • 太阳此起彼伏,月扶墙而上。按照常理,故事开始妩媚,恋人开始露骨。这不过是月的三分力道,月下黑,免不了过分焦灼。阴阳...
    温泉下销骨阅读 288评论 0 0