标签:
CentOS_6.5
$ sudo yum -y remove docker
$ yum install epel-release
$ sudo yum install docker-io
$ service docker start
$ yum -y install device-mapper-libs (-d 的错误)
$ docker pull daocloud.io/library/centos:7.1.15037.1.1503: Pulling from daocloud.io/library/centos
$ docker run -i -t -v /root/software/:/mnt/software/ 镜像ID /bin/bash
$ tar -zxf /mnt/software/apache-tomcat-7.0.69.tar.gz -C .
重命名$ mv apache-tomcat-7.0.69/ tomcat7/
$ tar -zxf /mnt/software/jdk-7u79-linux-x64.tar.gz -C .
重命名$ mv jdk1.7_79/ jdk7/
编辑 .bashrc 文件 $ vi ~/.bashrc
在文件中添加
export JAVA_HOME=/opt/jdk7
export PATH=$PATH:$JAVA_HOME
使用命令让环境变量生效
$ source ~/.bashrc
编写运行脚本 $ vi /root/run.sh
脚本内容如下
#!/bin/bash
source ~/.bashrc
sh /opt/tomcat/bin/catalina.sh run
添加脚本执行权限
$ chmod u+x /root/run.sh
退出容器 $ exit
$ docker ps -a
$ docker commit 上边的容器ID liyunke/javaweb:0.1
查看所有镜像 $ docker images
启动刚创建的镜像
$ docker run -d -p 58080:8080 --name javaweb liyunke/javaweb:0.1 /root/run.sh
访问tomcat首页(端口58080)
CentOS_7
$ vim /etc/yum.repos.d/docker.repo
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
$ yum install docker-engine
$ service docker start
标签:
原文地址:http://www.cnblogs.com/XiaoKe-GoUp/p/5632044.html