码迷,mamicode.com
首页 > 其他好文 > 详细

docker

时间:2016-08-30 12:14:19      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

1、安装redhat 6.5

2、vmware 桥接 redhat 静态ip 设置 (备忘)

查看vm 编辑 虚拟网络编辑器 是否有“vmnet0桥接模式”。若没有,到物理网卡下查看属性里是否有“VMWare Bridge protocol”。若无,安装此项服务

配置IP、Mask等网络参数

vi /etc/sysconfig/network-scripts/ifcfg-eth0 

DEVICE=eth0 HWADDR=00:0C:29:92:ED:6A TYPE=Ethernet UUID=88e1194a-5c35-4ac4-9933-69c712b66cc8 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=192.168.1.104 NETMASK=255.255.255.0 GATEWAY=192.168.1.1     DNS1=8.8.8.8 DNS2=8.8.4.4

 3、

RHEL的YUM源需要注册用户才能更新使用,由于CentOS和RHEL基本没有区别,并且CentOS已经被REHL收购。所以将RHEL的YUM源替换为CentOS即可。
问题如下:
[root@bogon ~]# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repolist: 0

解决方法:
1.清除原有RHEL的YUM及相关软件包。
rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa |grep python-urlgrabber|xargs rpm -e --nodeps

2.下载centos6的相关软件包。
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
*注释:这些软件包的具体的版本,请到http://mirrors.163.com/centos/6/os/x86_64/Packages/ 目录下,选择下载上述软件包。网上很多文章没法直接使用就是因为软件包的版本问题。

3.安装软件包。
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm yum-3.2.29-73.el6.centos.noarch.rpm
*注释yum-plugin-fastestmirror和yum-3.2.29要一起安装。

4.替换新的repo文件。
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
sed -i "s;\$releasever;6;g" CentOS6-Base-163.repo
mv rhel-source.repo rhel-source.repo.bak

5.执行yum repolist查看,如果显示出repo仓库列表,并显示软件包数量则OK。(或者使用yum makecache)

 

4、Install Docker on RHEL 6.5(EPEL)

4、安装相应的epel源
wget http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh  epel-release-6-8.noarch.rpm

5、安装docker
yum -y install docker-io

6、启动docker
启动docker进程:service docker start
查看docker进程:ps -ef |grep docker

 5、宿主机安装nginx(编译安装最新版本)

#下载最新版本:
 wget http://nginx.org/download/nginx-1.11.3.tar.gz
#解压
tar -zxvf nginx-1.11.3.tar.gz

mv nginx-1.11.3 /usr/local/nginx
cd /usr/local/nginx/
yum install -y pcre-devel 

#/bin/sh: line 0: cd: ../pcre-7.8: No such file or directory
#make[1]: *** [../pcre-7.8/Makefile] Error 1
#make[1]: Leaving directory `/usr/local/nginx‘
  #安装pcre-devel库(使Nginx支持http rewrite的模块)

  wget http://exim.mirror.fr/pcre/pcre-8.38.tar.gz

    tar -zxvf pcre-8.38.tar.gz

  mv pcre-8.38 /usr/local/
  cd /usr/local/pcre-8.38
   ./congigure
   make
   make install
#安装zlib 1.2.8
 wget http://zlib.net/zlib-1.2.8.tar.gz

  tar -zxvf zlib-1.2.8.tar.gz

  mv zlib-1.2.8 /usr/local/

  cd /usr/local/zlib-1.2.8/

  ./congigure
   make
   make install

./configure    --sbin-path=/usr/local/nginx/nginx    --conf-path=/usr/local/nginx/nginx.conf    --pid-path=/usr/local/nginx/nginx.pid    --with-http_ssl_module    --with-pcre=../pcre-8.38 --with-zlib=../zlib-1.2.8
#error: C compiler cc is not found
#如果安装出现在下面的错误是缺少编译环境。安装编译源码所需的工具和库 
yum install gcc gcc-c++ ncurses-devel perl 

#安装cmake,从http://www.cmake.org下载源码并编译安装 
yum -y install make gcc gcc-c++ ncurses-devel 
#./configure: error: the HTTP gzip module requires the zlib library.

yum -y install zlib zlib-devel 
#如果需要ssl功能需要openssl库 
#./configure: error: SSL modules require the OpenSSL library.

yum -y install openssl openssl--devel 
make 
make install 

 6、添加Nginx 到 service 启动

vi /etc/init.d/nginx 

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server  
#  
# chkconfig: - 85 15  
# description: Nginx is a high-performance web and proxy server.  
# It has a lot of features, but it‘s not for everyone.  
# processname: nginx  
# pidfile: /var/run/nginx.pid  
# config: /usr/local/nginx/conf/nginx.conf  
nginxd=/usr/local/nginx/sbin/nginx  
nginx_config=/usr/local/nginx/conf/nginx.conf  
nginx_pid=/usr/local/nginx/nginx.pid  
 
RETVAL=0  
prog="nginx" 
 
# Source function library.  
. /etc/rc.d/init.d/functions  
 
# Source networking configuration.  
. /etc/sysconfig/network  
 
# Check that networking is up.  
[ ${NETWORKING} = "no" ] && exit 0  
 
[ -x $nginxd ] || exit 0  
 
 
# Start nginx daemons functions.  
start() {  
 
if [ -e $nginx_pid ];then 
   echo "nginx already running...." 
   exit 1  
fi  
 
   echo -n $"Starting $prog: " 
   daemon $nginxd -c ${nginx_config}  
   RETVAL=$?  
   echo  
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx  
   return $RETVAL  
 
}  
 
 
# Stop nginx daemons functions.  
stop() {  
        echo -n $"Stopping $prog: " 
        killproc $nginxd  
        RETVAL=$?  
        echo  
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid  
}  
 
 
# reload nginx service functions.  
reload() {  
 
    echo -n $"Reloading $prog: " 
 $nginxd -s reload  
    #if your nginx version is below 0.8, please use this command: "kill -HUP `cat ${nginx_pid}`" 
    RETVAL=$?  
    echo  
 
}  
 
# See how we were called.  
case "$1" in 
start)  
        start  
        ;;  
 
stop)  
        stop  
        ;;  
 
reload)  
        reload  
        ;;  
 
restart)  
        stop  
        start  
        ;;  
 
status)  
        status $prog  
        RETVAL=$?  
        ;;  
*)  
        echo $"Usage: $prog {start|stop|restart|reload|status|help}" 
        exit 1  
esac  
 
exit $RETVAL 
cd /etc/rc.d/init.d
chmod +x nginx
/sbin/chkconfig --level 345 nginx on
service nginx start

  

7、开启80端口 输入IP地址应该可以访问了

vi /etc/sysconfig/iptables
service iptables restart

8、准备jdk tomcat  mysql 等

cd /software
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz"

 

9、准备容器image    http://my.oschina.net/huangyong/blog/372491?fromerr=kHrZPM01

#pull image
docker pull centos:centos7
#查看镜像
docker images
#启动并进去容器bash   d83a55af4e75 为image id
#docker run <相关参数> <镜像 ID> <初始命令>
#将宿主机的/software/挂载到image的/mnt/software/以共享文件
docker run -i -t -v /software/:/mnt/software/ d83a55af4e75 /bin/bash

10、进入image并安装jdk

cd /opt
tar -zxf /mnt/software/jdk-7u75-linux-x64.tar.gz -C .
mv jdk1.7.0_75/ jdk/

11、安装tomcat

tar -zxf /mnt/software/apache-tomcat-7.0.70.tar.gz -C .
mv apache-tomcat-7.0.70/ tomcat/

12、设置环境变量

vi ~/.bashrc

#文件末尾添加
export JAVA_HOME=/opt/jdk
export PATH=$PATH:$JAVA_HOME

#需要使用source命令,让环境变量生效:
source ~/.bashrc

13、运行脚本

vi /root/run.sh

#内容为:

#!/bin/bash
source ~/.bashrc
sh /opt/tomcat/bin/catalina.sh run
#添加权限
chmod u+x /root/run.sh

14、创建新的镜像

#退出image
exit
#查看所有镜像
docker ps -a 
#创建新的镜像
docker commit 6d20712c0e0c dingbs/javaweb:0.1
#查看最新镜像情况
docker images

 

15、

 

 

 

 

 

 

安装 Tomcat

docker

标签:

原文地址:http://www.cnblogs.com/tour2013/p/5814174.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!