- 浏览: 3422477 次
- 性别:
- 来自: 珠海
文章分类
- 全部博客 (1633)
- Java (250)
- Android&HTML5 (111)
- Struts (10)
- Spring (236)
- Hibernate&MyBatis (115)
- SSH (49)
- jQuery插件收集 (55)
- Javascript (145)
- PHP (77)
- REST&WebService (18)
- BIRT (27)
- .NET (7)
- Database (105)
- 设计模式 (16)
- 自动化和测试 (19)
- Maven&Ant (43)
- 工作流 (36)
- 开源应用 (156)
- 其他 (16)
- 前台&美工 (119)
- 工作积累 (0)
- OS&Docker (83)
- Python&爬虫 (28)
- 工具软件 (157)
- 问题收集 (61)
- OFbiz (6)
- noSQL (12)
最新评论
-
HEZR曾嶸:
你好博主,这个不是很理解,能解释一下嘛//左边+1,上边+1, ...
java 两字符串相似度计算算法 -
天使建站:
写得不错,可以看这里,和这里的这篇文章一起看,有 ...
jquery 遍历对象、数组、集合 -
xue88ming:
很有用,谢谢
@PathVariable映射出现错误: Name for argument type -
jnjeC:
厉害,困扰了我很久
MyBatis排序时使用order by 动态参数时需要注意,用$而不是# -
TopLongMan:
非常好,很实用啊。。
PostgreSQL递归查询实现树状结构查询
centos安装redis3为系统服务 http://my.oschina.net/haoqoo/blog/464247
centos 安装Supervisor
http://www.alphadevx.com/a/455-Installing-Supervisor-and-Superlance-on-CentOS
网络设定
# 创建网络
brctl addbr br0
ip link set dev br0 up
ip addr add 192.168.2.1/24 dev br0
# 创建容器
# 方法1
DB=$(docker run -d --name db pandy/centos7-postgresql931)
pipework br0 $DB 192.168.2.100/24
# 方法2
docker run -d --name db pandy/centos7-postgresql931
pipework br0 db 192.168.2.100/24
# 删除容器之后删除网络
ip link set br0 down
brctl delbr br0
SSH
*********************************************************************
Dockerfile
====================
构建:
docker build -t pandy/ssh .
docker run -d -name ssh pandy/ssh
pipework br0 apache 192.168.2.103/24;
Java
*********************************************************************
官方openJDK: https://registry.hub.docker.com/_/java/
OracleJDK: https://registry.hub.docker.com/u/alsanium/java/
centos oracleJDK https://registry.hub.docker.com/u/j728c/java/dockerfile/, 里面应该继续支持解压和压缩:yum -y install tar zip unzip
自己修改后的Dockerfile
====================================
构建:docker build -t pandy/centos7-java7 .
使用:docker run -t -i xxx/xxxx /bin/bash
Apache
*********************************************************************
Dockerfile参考: https://registry.hub.docker.com/u/skydiverss/apache-centos/dockerfile/
构建
docker build -t pandy/apache .
docker run -d -p 81:80 -e SERVERADMIN="mail@domain.com" -e DEFAULT_LOGS_DIR="/logs/httpd/defaults" --name=apache -v /home/pandy/docker-resources/apache/conf:/etc/httpd/conf -v /home/pandy/docker-resources/apache/html:/var/www/html pandy/apache //这里不用后面的一些命令, 会自动调用Dockerfile里面的CMD内容
Memcached, 注意,这个没测试成功.
*********************************************************************
Dockerfile参考: https://registry.hub.docker.com/u/centminmod/docker-centos7-memcached/
构建 参考 https://registry.hub.docker.com/u/centminmod/docker-centos7-memcached/
docker build -t pandy/memcached .
docker run --name memcached -d -p 33211:11211 -t pandy/memcached memcached -m 512 -t 2
memcached命令详解:http://nkcoder.github.io/blog/20140215/memcached-usage-parameters-commands/
Redis
*********************************************************************
Dockerfile参考: https://registry.hub.docker.com/u/zhaowh/centos-redis/dockerfile/
构建
docker build -t pandy/redis .
docker run -d -p 6379:6379 pandy/redis
Tomcat
*********************************************************************
官方:https://registry.hub.docker.com/_/tomcat/
centos例子:
1. https://registry.hub.docker.com/u/consol/tomcat-7.0/dockerfile/
2. https://registry.hub.docker.com/u/malderhout/tomcat/dockerfile/
, 里面应该继续支持解压和压缩:yum -y install tar zip unzip
自己修改后的Dockerfile
====================================
supervisord.conf文件代码
[supervisord]
nodaemon=true
[program:tomcat]
command=/opt/tomcat/bin/startup.sh
构建:
docker build -t pandy/centos7-java7-tomcat7 . //构建
docker run -t -i -d --name web -p 81:8080 pandy/centos7-java7-tomcat7 /bin/bash //创建, 这个不会自动启动tomcat
docker run -d --name web -p 81:8080 pandy/centos7-java7-tomcat7 /usr/bin/supervisord //这个会自动启动tomcat
docker run -t -d --name web -p 81:8080 -v /home/pandy/docker-resources/tomcat/webapps:/opt/tomcat/webapps pandy/centos7-java7-tomcat7 /usr/bin/supervisord //这个会自动启动tomcat, 并挂载webapps, 同时可以挂载logs, work等文件夹进去,注意,现在为什么挂载要使用/opt/tomcat7,而不是/opt/tomcat?不是已经做软链接了么?
注意:关于tomcat,在http://support.inovatrend.com/confluence/display/PUBLOG/Java,+Tomcat+and+Docker,介绍
比如:在run追加参数-e "JAVA_OPTS=-Dspring.profiles.active=demo -Xmx1024m", 可以设定一些变量.
但是https://registry.hub.docker.com/u/maluuba/tomcat7/看到
docker run --cap-add SYS_PTRACE -it -p 8080:8080 -e JAVA_OPTS='-Dsome.property=value' -e Xmx=2048m -v deployment:/deployment maluuba/tomcat7
待测试看到底是哪种情况是对的
Postgresql
*********************************************************************
原文:https://registry.hub.docker.com/u/autenta/centos-postgresql/
Image for CentOS 6 and PostgreSQL 9.3 that create database with sv_SE.UTF8 locale.
Source: https://github.com/jotu/docker-centos-postgresql
OBS! This is a simple version and should only be used in development or testing.
Getting Started
You can build this container from Github via
docker pull autenta/centos-postgresql
To run the container you can do the following:
docker run -p 5432:5432 -d -t autenta/centos-postgresql
psql -U postgres -h localhost -p 5432
安装后默认密码为空.
Dockerfile安装
可以使用它的Dockerfile(修改成了centos:7):
vim Dockerfile
=========================================代码如下:
构建
docker build -t pandy/centos7-postgresql931 .
docker run -p 5431:5432 -t -d --name db -v /home/pandy/docker-resources/tb_space/:/usr/pgsql-9.3/tb_space pandy/centos7-postgresql931 //启动并挂载表空间目录
psql -U postgres -h localhost -p 5432
mysql centos6
参考:https://hub.docker.com/r/codebear4/centos6-mysql/~/dockerfile/
bootstrap.sh
create_mysql_user.sh
my.cnf
Dockerfile
docker build -t pandy/centos6-mysql .
docker run --name lamp -d -p 3307:3306 pandy/centos6-mysql
apache + php centos6
docker build -t pandy/centos6-php .
docker run --name lamp -d -p 81:80 pandy/centos6-php
JAVA+Redis+Tomcat
*********************************************************************
supervisord.conf文件
================================
[supervisord]
nodaemon=true
[program:redis]
command=redis-server /etc/redis/redis.conf
[program:tomcat]
command=/opt/tomcat/bin/startup.sh
构建:
docker build -t pandy/centos7-java7-redis3-tomcat7 . //构建
docker run -t -i -d --name web -p 81:8080 pandy/centos7-java7-redis3-tomcat7 /bin/bash //创建, 这个不会自动启动tomcat
docker run -d --name web -p 81:8080 pandy/centos7-java7-redis3-tomcat7 /usr/bin/supervisord //这个会自动启动tomcat
docker run -t -d --name web -p 81:8080 -v /home/pandy/docker-resources/tomcat/webapps:/opt/tomcat/webapps pandy/centos7-java7-redis3-tomcat7 /usr/bin/supervisord //这个会自动启动tomcat, 并挂载webapps, 同时可以挂载logs, work等文件夹进去
centos 安装Supervisor
http://www.alphadevx.com/a/455-Installing-Supervisor-and-Superlance-on-CentOS
网络设定
# 创建网络
brctl addbr br0
ip link set dev br0 up
ip addr add 192.168.2.1/24 dev br0
# 创建容器
# 方法1
DB=$(docker run -d --name db pandy/centos7-postgresql931)
pipework br0 $DB 192.168.2.100/24
# 方法2
docker run -d --name db pandy/centos7-postgresql931
pipework br0 db 192.168.2.100/24
# 删除容器之后删除网络
ip link set br0 down
brctl delbr br0
SSH
*********************************************************************
Dockerfile
====================
FROM centos:centos7 MAINTAINER Pandy <panyongzheng@163.com> RUN yum update -y RUN yum install -y openssh-server which RUN mkdir -p /var/run/sshd && \ echo "root:root" | chpasswd ADD init-functions /etc/rc.d/init.d/functions RUN /usr/sbin/sshd-keygen RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config RUN sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config CMD /usr/sbin/sshd -D EXPOSE 22
构建:
docker build -t pandy/ssh .
docker run -d -name ssh pandy/ssh
pipework br0 apache 192.168.2.103/24;
Java
*********************************************************************
官方openJDK: https://registry.hub.docker.com/_/java/
OracleJDK: https://registry.hub.docker.com/u/alsanium/java/
centos oracleJDK https://registry.hub.docker.com/u/j728c/java/dockerfile/, 里面应该继续支持解压和压缩:yum -y install tar zip unzip
自己修改后的Dockerfile
====================================
FROM centos:centos7 MAINTAINER Pandy <panyongzheng@163.com> # update repo RUN yum -y update RUN yum -y install supervisor # install jdk then remove the rpm #RUN yum install -y wget && wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.rpm #RUN rpm -Uvh jdk-7u75-linux-x64.rpm && rm jdk-7u75-linux-x64.rpm # set JAVA_HOME, CLASSPATH, PATH #ENV JAVA_HOME /usr/java/jdk1.7.0_75 COPY jdk-7u72-linux-x64.rpm /tmp/jdk-7u72-linux-x64.rpm RUN rpm -ivh /tmp/jdk-7u72-linux-x64.rpm && rm /tmp/jdk-7u72-linux-x64.rpm ENV JAVA_HOME /usr/java/jdk1.7.0_72 #TEST RUN java -version RUN javac -version # install tar,zip,unzip RUN yum -y install tar zip unzip
构建:docker build -t pandy/centos7-java7 .
使用:docker run -t -i xxx/xxxx /bin/bash
Apache
*********************************************************************
Dockerfile参考: https://registry.hub.docker.com/u/skydiverss/apache-centos/dockerfile/
FROM centos:centos7 MAINTAINER Pandy <panyongzheng@163.com> # Update latest packages RUN yum -y update #COMMON #============================================== #RUN yum -y install vim # Install REMI and EPEL repositories #RUN yum -y install localinstall http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm #RUN yum -y localinstall http://rpms.famillecollet.com/enterprise/remi-release-6.rpm COPY epel-release-6-8.noarch.rpm /tmp/epel-release-6-8.noarch.rpm RUN rpm -Uvh /tmp/epel-release-6-8.noarch.rpm && rm /tmp/epel-release-6-8.noarch.rpm # Install httpd, php 5.4 and extensions RUN yum list httpd RUN yum -y --enablerepo=remi install httpd # Clean yum cache RUN yum clean all #Add Apache an PHP config files whith variables #ADD httpd.conf /etc/httpd/conf/httpd.conf #Apache ENV ENV APACHE_TIMEOUT 60 ENV APACHE_KEEPALIVE Off ENV APACHE_MAXKEEPALIVEREQUESTS 100 ENV APACHE_KEEPALIVETIMEOUT 15 ENV APACHE_DEFAULT_LOGS_DIR logs ENV APACHE_SERVERADMIN root@localhost ENV APACHE_DEFAULT_LOGS_LEVEL warn #PHP ENV ENV PHP_SHORTOPENTAG Off ENV PHP_MEMORYLIMIT 128M ENV PHP_DISPLAYERROR Off EXPOSE 80 VOLUME ["/var/www/html","/var/www/cgi-bin"] CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
构建
docker build -t pandy/apache .
docker run -d -p 81:80 -e SERVERADMIN="mail@domain.com" -e DEFAULT_LOGS_DIR="/logs/httpd/defaults" --name=apache -v /home/pandy/docker-resources/apache/conf:/etc/httpd/conf -v /home/pandy/docker-resources/apache/html:/var/www/html pandy/apache //这里不用后面的一些命令, 会自动调用Dockerfile里面的CMD内容
Memcached, 注意,这个没测试成功.
*********************************************************************
Dockerfile参考: https://registry.hub.docker.com/u/centminmod/docker-centos7-memcached/
FROM centos:centos7 MAINTAINER Pandy <panyongzheng@163.com> #Commom RUN yum -y update # Setup Memcached RUN yum -y install epel-release nano which hostname && rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm && yum update -y && yum install -y memcached --enablerepo=remi && yum clean all && rm -rf /var/cache/* && echo "" > /var/log/yum.log # Clean yum cache RUN yum clean all # Expose 11211 to outside EXPOSE 11211 # Service to run CMD /usr/bin/memcached -m 64 -p 11211 -c 4096 -b 4096 -t 2 -R 200 -n 72 -f 1.25 -u memcached -o slab_reassign slab_automove
构建 参考 https://registry.hub.docker.com/u/centminmod/docker-centos7-memcached/
docker build -t pandy/memcached .
docker run --name memcached -d -p 33211:11211 -t pandy/memcached memcached -m 512 -t 2
memcached命令详解:http://nkcoder.github.io/blog/20140215/memcached-usage-parameters-commands/
Redis
*********************************************************************
Dockerfile参考: https://registry.hub.docker.com/u/zhaowh/centos-redis/dockerfile/
FROM centos:centos7 MAINTAINER Pandy <panyongzheng@163.com> RUN yum -y update # Install gcc #RUN yum -y install localinstall http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm #RUN yum -y localinstall http://rpms.famillecollet.com/enterprise/remi-release-6.rpm COPY epel-release-6-8.noarch.rpm /tmp/epel-release-6-8.noarch.rpm RUN rpm -Uvh /tmp/epel-release-6-8.noarch.rpm && rm /tmp/epel-release-6-8.noarch.rpm RUN yum -y install wget tar gcc-c++ automake autoconf libtool make #安装Supervisor #=============================================== #RUN yum -y install supervisor RUN yum install -y python-setuptools RUN easy_install supervisor RUN supervisord --version RUN yum clean all # Install Redis. COPY redis-stable.tar.gz /tmp/redis-stable.tar.gz RUN \ cd /tmp && \ # wget http://download.redis.io/redis-stable.tar.gz && \ #注释掉了 tar xvzf redis-stable.tar.gz && \ cd redis-stable && \ make && \ make install && \ cp -f src/redis-sentinel /usr/local/bin && \ mkdir -p /etc/redis && \ cp -f *.conf /etc/redis && \ rm -rf /tmp/redis-stable* && \ sed -i 's/^\(bind .*\)$/# \1/' /etc/redis/redis.conf && \ sed -i 's/^\(daemonize .*\)$/# \1/' /etc/redis/redis.conf && \ sed -i 's/^\(dir .*\)$/# \1\ndir \/data/' /etc/redis/redis.conf && \ sed -i 's/^\(logfile .*\)$/# \1/' /etc/redis/redis.conf VOLUME ["/data"] WORKDIR /data EXPOSE 6379 #启动命令:redis-server /etc/redis/redis.conf #CMD ["redis-server", "/etc/redis/redis.conf"] COPY supervisord-redis.conf /etc/supervisord.conf #启动supervisord CMD ["/usr/bin/supervisord"]
构建
docker build -t pandy/redis .
docker run -d -p 6379:6379 pandy/redis
Tomcat
*********************************************************************
官方:https://registry.hub.docker.com/_/tomcat/
centos例子:
1. https://registry.hub.docker.com/u/consol/tomcat-7.0/dockerfile/
2. https://registry.hub.docker.com/u/malderhout/tomcat/dockerfile/
, 里面应该继续支持解压和压缩:yum -y install tar zip unzip
自己修改后的Dockerfile
====================================
FROM centos:centos7 MAINTAINER Pandy <panyongzheng@163.com> # UPDATE RUN yum -y update #安装Supervisor #=============================================== #RUN yum -y install supervisor RUN yum install -y python-setuptools RUN easy_install supervisor RUN supervisord --version #Common #=============================================== # INSTALL packages RUN yum -y install wget tar zip unzip #Java #=============================================== #RUN yum install -y wget && wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.rpm #RUN rpm -Uvh jdk-7u75-linux-x64.rpm && rm jdk-7u75-linux-x64.rpm # set JAVA_HOME, CLASSPATH, PATH #ENV JAVA_HOME /usr/java/jdk1.7.0_75 COPY jdk-7u72-linux-x64.rpm /tmp/jdk-7u72-linux-x64.rpm RUN rpm -ivh /tmp/jdk-7u72-linux-x64.rpm && rm /tmp/jdk-7u72-linux-x64.rpm ENV JAVA_HOME /usr/java/jdk1.7.0_72 #TEST RUN java -version RUN javac -version #Tomcat #=============================================== # TOMCAT version ENV TOMCAT_VERSION 7.0.61 # INSTALL TOMCAT #RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz -O /tmp/tomcat7.tar.gz COPY apache-tomcat-7.0.61.tar.gz /tmp/tomcat7.tar.gz # UNPACK RUN tar xzf /tmp/tomcat7.tar.gz -C /opt RUN ln -s /opt/apache-tomcat-${TOMCAT_VERSION} /opt/tomcat RUN rm /tmp/tomcat7.tar.gz # REMOVE APPS 删除不必要的应用 RUN rm -rf /opt/tomcat/webapps/examples /opt/tomcat/webapps/docs # Add roles, 手动下载对应版本的tomcat, 然后修改tomcat-users.xml, 在进行覆盖 #ADD tomcat-users.xml /opt/tomcat/conf/ # SET CATALINE_HOME and PATH ENV CATALINA_HOME /opt/tomcat ENV PATH $PATH:$CATALINA_HOME/bin #copy conf to image 位置为其中之一, 推荐使用最后一个: #etc/supervisord.conf, supervisord.conf, supervisord.conf, #etc/supervisord.conf, /etc/supervisord.conf #COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY supervisord-tomcat.conf /etc/supervisord.conf # SET PORT and start TOMCAT EXPOSE 22 80 8080 #启动supervisord CMD ["/usr/bin/supervisord"] #启动Tomcat, 已经启动了supervisord, 那么这里是否还需要? 待确定. #CMD $CATALINA_HOME/bin/catalina.sh run #CMD $CATALINA_HOME/bin/startup.sh
supervisord.conf文件代码
[supervisord]
nodaemon=true
[program:tomcat]
command=/opt/tomcat/bin/startup.sh
构建:
docker build -t pandy/centos7-java7-tomcat7 . //构建
docker run -t -i -d --name web -p 81:8080 pandy/centos7-java7-tomcat7 /bin/bash //创建, 这个不会自动启动tomcat
docker run -d --name web -p 81:8080 pandy/centos7-java7-tomcat7 /usr/bin/supervisord //这个会自动启动tomcat
docker run -t -d --name web -p 81:8080 -v /home/pandy/docker-resources/tomcat/webapps:/opt/tomcat/webapps pandy/centos7-java7-tomcat7 /usr/bin/supervisord //这个会自动启动tomcat, 并挂载webapps, 同时可以挂载logs, work等文件夹进去,注意,现在为什么挂载要使用/opt/tomcat7,而不是/opt/tomcat?不是已经做软链接了么?
注意:关于tomcat,在http://support.inovatrend.com/confluence/display/PUBLOG/Java,+Tomcat+and+Docker,介绍
比如:在run追加参数-e "JAVA_OPTS=-Dspring.profiles.active=demo -Xmx1024m", 可以设定一些变量.
但是https://registry.hub.docker.com/u/maluuba/tomcat7/看到
docker run --cap-add SYS_PTRACE -it -p 8080:8080 -e JAVA_OPTS='-Dsome.property=value' -e Xmx=2048m -v deployment:/deployment maluuba/tomcat7
待测试看到底是哪种情况是对的
Postgresql
*********************************************************************
原文:https://registry.hub.docker.com/u/autenta/centos-postgresql/
Image for CentOS 6 and PostgreSQL 9.3 that create database with sv_SE.UTF8 locale.
Source: https://github.com/jotu/docker-centos-postgresql
OBS! This is a simple version and should only be used in development or testing.
Getting Started
You can build this container from Github via
docker pull autenta/centos-postgresql
To run the container you can do the following:
docker run -p 5432:5432 -d -t autenta/centos-postgresql
psql -U postgres -h localhost -p 5432
安装后默认密码为空.
Dockerfile安装
可以使用它的Dockerfile(修改成了centos:7):
vim Dockerfile
=========================================代码如下:
# FROM centos:centos7 MAINTAINER Pandy <panyongzheng@163.com> #Common #=============================================== # INSTALL packages RUN yum -y update RUN yum -y install wget tar zip unzip #Postgresql #=============================================== RUN yum reinstall -y glibc-common RUN localedef -i sv_SE -f UTF-8 sv_SE.utf8 # install pg repo RUN rpm -i http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm # install server RUN yum install -y postgresql93-server postgresql93-contrib #初始化数据库 RUN su - postgres -c '/usr/pgsql-9.3/bin/initdb --locale=sv_SE.UTF-8 -D /var/lib/pgsql/data' #创建表空间文件夹, 这样做也没成功 #CREATE TABLESPACE tablespacename OWNER postgres LOCATION '/var/tablespace'; #RUN mkdir -p "/usr/pgsql-9.3/tb_space" #RUN chown postgres /usr/pgsql-9.3/tb_space #RUN chmod u+x /usr/pgsql-9.3/tb_space #RUN ls -l /usr/pgsql-9.3 # set permissions to allow logins, trust the bridge, this is the default for docker YMMV RUN echo "host all all 0.0.0.0/0 trust" >> /var/lib/pgsql/data/pg_hba.conf #listen on all interfaces RUN echo "listen_addresses='*'" >> /var/lib/pgsql/data/postgresql.conf EXPOSE 5432 VOLUME ["/var/lib/pgsql/data"] CMD su - postgres -c "/usr/pgsql-9.3/bin/postgres -D /var/lib/pgsql/data"
构建
docker build -t pandy/centos7-postgresql931 .
docker run -p 5431:5432 -t -d --name db -v /home/pandy/docker-resources/tb_space/:/usr/pgsql-9.3/tb_space pandy/centos7-postgresql931 //启动并挂载表空间目录
psql -U postgres -h localhost -p 5432
mysql centos6
参考:https://hub.docker.com/r/codebear4/centos6-mysql/~/dockerfile/
bootstrap.sh
#!/bin/bash if [ ! -f /var/lib/mysql/ibdata1 ]; then echo "No Database(s)! Initializing..." echo "Running mysql_install_db" mysql_install_db echo "Starting up mysqld_safe" /usr/bin/mysqld_safe & sleep 10s echo "Creating user that define use ENV" /create_mysql_user.sh killall mysqld sleep 10s echo "Restarting" fi /usr/bin/mysqld_safe echo "Ok."
create_mysql_user.sh
#!/bin/bash mysql -uroot -e "CREATE USER '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASS}'" mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO '${MYSQL_USER}'@'%' WITH GRANT OPTION"
my.cnf
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
Dockerfile
FROM centos:centos6 MAINTAINER Pandy<panyongzhegn@163.com> # Update latest packages RUN yum -y update # Install REMI and EPEL repositories RUN yum -y localinstall http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm RUN yum -y localinstall http://rpms.famillecollet.com/enterprise/remi-release-6.rpm RUN yum --enablerepo=base clean metadata RUN yum install -yq mysql-server ADD my.cnf /etc/my.cnf EXPOSE 3306 #配置mysql账户和密码 ENV MYSQL_USER root ENV MYSQL_PASS 123456 ADD create_mysql_user.sh /create_mysql_user.sh RUN chmod +x /create_mysql_user.sh ADD bootstrap.sh /bootstrap RUN chmod +x /bootstrap ENTRYPOINT ["/bootstrap"]
docker build -t pandy/centos6-mysql .
docker run --name lamp -d -p 3307:3306 pandy/centos6-mysql
apache + php centos6
FROM centos:centos6 MAINTAINER Pandy<panyongzhegn@163.com> # Update latest packages RUN yum -y update # Install REMI and EPEL repositories RUN yum -y localinstall http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm RUN yum -y localinstall http://rpms.famillecollet.com/enterprise/remi-release-6.rpm # apache is successfull. httpd-2.2.15-47.el6.centos.x86_64 RUN yum -y install httpd #Apache ENV ENV APACHE_TIMEOUT 60 ENV APACHE_KEEPALIVE Off ENV APACHE_MAXKEEPALIVEREQUESTS 100 ENV APACHE_KEEPALIVETIMEOUT 15 ENV APACHE_DEFAULT_LOGS_DIR logs ENV APACHE_SERVERADMIN root@localhost ENV APACHE_DEFAULT_LOGS_LEVEL warn #PHP ENV ENV PHP_SHORTOPENTAG Off ENV PHP_MEMORYLIMIT 128M ENV PHP_DISPLAYERROR Off ENV PHP_TIMEZONE "UTC" ENV APACHE_RUN_USER apache ENV APACHE_RUN_GROUP apache ENV APACHE_LOG_DIR /etc/httpd/logs/ CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"] # php is fialed. 5.3.3-46.el6_6 RUN yum install -y php php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml php-common php-mbstring php-mcrypt php-xml ADD www/info.php /var/www/html/ #EXPOSE 80 3306 #RUN yum install -y python-setuptools #RUN easy_install supervisor #RUN supervisord --version #ADD supervisord.conf /etc/ #CMD ["supervisord", "-n"] #CMD ["/usr/bin/supervisord", "-n"]
docker build -t pandy/centos6-php .
docker run --name lamp -d -p 81:80 pandy/centos6-php
JAVA+Redis+Tomcat
*********************************************************************
FROM centos:centos7 MAINTAINER Pandy <panyongzheng@163.com> # UPDATE RUN yum -y update #安装Supervisor #=============================================== #RUN yum -y install supervisor RUN yum install -y python-setuptools RUN easy_install supervisor RUN supervisord --version #Common #=============================================== # INSTALL packages RUN yum -y install wget tar zip unzip #Java #=============================================== #RUN yum install -y wget && wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.rpm #RUN rpm -Uvh jdk-7u75-linux-x64.rpm && rm jdk-7u75-linux-x64.rpm # set JAVA_HOME, CLASSPATH, PATH #ENV JAVA_HOME /usr/java/jdk1.7.0_75 COPY jdk-7u72-linux-x64.rpm /tmp/jdk-7u72-linux-x64.rpm RUN rpm -ivh /tmp/jdk-7u72-linux-x64.rpm && rm /tmp/jdk-7u72-linux-x64.rpm ENV JAVA_HOME /usr/java/jdk1.7.0_72 #TEST RUN java -version RUN javac -version #Redis #=============================================== # Install gcc #RUN yum -y install localinstall http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm #RUN yum -y localinstall http://rpms.famillecollet.com/enterprise/remi-release-6.rpm COPY epel-release-6-8.noarch.rpm /tmp/epel-release-6-8.noarch.rpm RUN rpm -Uvh /tmp/epel-release-6-8.noarch.rpm && rm /tmp/epel-release-6-8.noarch.rpm RUN yum -y install --enablerepo=epel gcc jemalloc.x86_64 jemalloc-devel.x86_64 RUN yum -y install wget tar gcc-c++ automake autoconf libtool make RUN yum clean all # Install Redis. COPY redis-stable.tar.gz /tmp/redis-stable.tar.gz RUN \ cd /tmp && \ # wget http://download.redis.io/redis-stable.tar.gz && \ #注释掉了 tar xvzf redis-stable.tar.gz && \ cd redis-stable && \ make && \ make install && \ cp -f src/redis-sentinel /usr/local/bin && \ mkdir -p /etc/redis && \ cp -f *.conf /etc/redis && \ rm -rf /tmp/redis-stable* && \ sed -i 's/^\(bind .*\)$/# \1/' /etc/redis/redis.conf && \ sed -i 's/^\(daemonize .*\)$/# \1/' /etc/redis/redis.conf && \ sed -i 's/^\(dir .*\)$/# \1\ndir \/data/' /etc/redis/redis.conf && \ sed -i 's/^\(logfile .*\)$/# \1/' /etc/redis/redis.conf VOLUME ["/data"] WORKDIR /data EXPOSE 6379 #CMD ["redis-server", "/etc/redis/redis.conf"] #Tomcat #=============================================== # TOMCAT version ENV TOMCAT_VERSION 7.0.61 # INSTALL TOMCAT #RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz -O /tmp/tomcat7.tar.gz COPY apache-tomcat-7.0.61.tar.gz /tmp/tomcat7.tar.gz # UNPACK RUN tar xzf /tmp/tomcat7.tar.gz -C /opt RUN ln -s /opt/apache-tomcat-${TOMCAT_VERSION} /opt/tomcat RUN rm /tmp/tomcat7.tar.gz # REMOVE APPS 删除不必要的应用 RUN rm -rf /opt/tomcat/webapps/examples /opt/tomcat/webapps/docs # Add roles, 手动下载对应版本的tomcat, 然后修改tomcat-users.xml, 在进行覆盖 #ADD tomcat-users.xml /opt/tomcat/conf/ # SET CATALINE_HOME and PATH ENV CATALINA_HOME /opt/tomcat ENV PATH $PATH:$CATALINA_HOME/bin # 发布端口 EXPOSE 22 80 8080 #copy conf to image COPY supervisord.conf /etc/supervisord.conf #启动supervisord CMD ["/usr/bin/supervisord"]
supervisord.conf文件
================================
[supervisord]
nodaemon=true
[program:redis]
command=redis-server /etc/redis/redis.conf
[program:tomcat]
command=/opt/tomcat/bin/startup.sh
构建:
docker build -t pandy/centos7-java7-redis3-tomcat7 . //构建
docker run -t -i -d --name web -p 81:8080 pandy/centos7-java7-redis3-tomcat7 /bin/bash //创建, 这个不会自动启动tomcat
docker run -d --name web -p 81:8080 pandy/centos7-java7-redis3-tomcat7 /usr/bin/supervisord //这个会自动启动tomcat
docker run -t -d --name web -p 81:8080 -v /home/pandy/docker-resources/tomcat/webapps:/opt/tomcat/webapps pandy/centos7-java7-redis3-tomcat7 /usr/bin/supervisord //这个会自动启动tomcat, 并挂载webapps, 同时可以挂载logs, work等文件夹进去
- httpd.conf.2.4.zip (4.6 KB)
- 下载次数: 0
- redis-stable3.x.tar.gz (1.3 MB)
- 下载次数: 0
- supervisord-redis.conf.zip (270 Bytes)
- 下载次数: 0
- supervisord-tomcat.conf.zip (267 Bytes)
- 下载次数: 0
- supervisord.conf.zip (283 Bytes)
- 下载次数: 0
发表评论
-
应用行为活动监测器 Sysdig Falco
2016-05-19 13:03 1289http://www.oschina.net/p/sysdig ... -
Fedora安装Redis
2016-05-04 08:56 1413管理工具: centos6.3下安装phpredisadmin ... -
redis-install.sh
2016-05-04 08:56 4#!/bin/bash # From here: http: ... -
redis 集群中Session解决方案之Spring Session
2016-05-04 08:54 1315集群中Session解决方案之Spring Session h ... -
使用Spring-data进行Redis操作
2016-05-04 08:54 4791使用Spring-data进行Redis操作 http://z ... -
Shiro集群实现
2016-05-04 08:53 2313apache shiro集群实现(一) session共享 h ... -
服务器自动化操作 RunDeck
2016-05-03 14:04 1716http://www.oschina.net/p/rundec ... -
安装Hadoop, Hbase, Phoenix
2016-04-22 09:22 1484http://my.oschina.net/jrrx/blog ... -
shell中读写mysql数据库
2016-03-13 15:32 1394http://mingxinglai.com/cn/2013/ ... -
container和主机(host)之间的文件拷贝
2016-02-04 21:33 1362http://www.cnblogs.com/lemonbar ... -
在linux操作系统下注销、关机、重启的简单命令
2016-01-31 15:28 1234一、注销的命令——Logout 是登陆的相对操作,登陆系统后, ... -
Linux如何查找大文件或目录总结
2016-01-28 22:44 1286http://my.oschina.net/u/1034537 ... -
Linux 查看磁盘空间命令
2016-01-14 22:08 1234df、du、fdisk:Linux磁盘 ... -
Linux下的压缩和解压
2015-11-10 16:13 1097Linux下的压缩(zip)解压(unzip)缩命令 http ... -
Linux下安装FFmpeg
2015-10-29 14:00 1579在线安装: 在 Ubuntu/Debian/Fedora 系统 ... -
Linux的tmpfs文件系统
2015-10-27 22:39 1058详细看原文:http://futureinhands.itey ... -
linux shell 中"2>&1"含义
2015-10-26 15:09 1267export date_str=$(date "+% ... -
管理Redis的Web工具 PyRedisAdmin
2015-10-19 20:36 1106http://www.oschina.net/p/pyredi ... -
centos 6.5 普通用户 开启自动运行
2015-10-15 19:30 4CentOS tomcat普通用户执行配置安装 http:// ... -
linux 统计文件夹大小
2015-10-13 22:25 1298linux 统计文件夹大小 http://www.51tes ...
相关推荐
vagrant 安装docker docker 安装mysql 、redis、kafka、 自启动
docker上的redis离线镜像redis.tar, 用于在docker上离线安装redis
docker redis镜像 用于在docker中导入redis的镜像 执行docker load -i redis.tar 即可完成导入操作
docker安装mysql、redis、nginx shell脚本
Macbook Pro进行Docker安装Redis并配置Redis持久化
docker安装redis时,可以使用的配置文件
docker 安装单机版redis
docker-compose构建Redis哨兵模式镜像包
这里我们将详细探讨如何利用Docker Compose部署Redis的主从哨兵配置和集群高可用性解决方案。 首先,Docker Compose是一个强大的工具,可以让我们通过YAML文件定义和运行多容器的Docker应用。在这个场景下,我们...
docker安装 mysql安装 tomcat安装 redis安装 组件之间的互连 挂载
docker离线安装redis镜像
docker、docker-compose 一键安装redis集群 (一台虚拟机上安装的伪集群,学习使用,可以修改文件配置相关参数,非原创,亲测可用) 第一步 /usr/local/下依次建docker、redis目录“/usr/local/docker/redis” 第二步 ...
1.先运行 createFile.py 输入宿主机IP地址,输入redis密码 2.按照控制台输出执行docker-compose up -d 启动命令 3.启动成功后执行加入集群命令即可
自己打包的redis镜像,仅仅3.7M,使用 docker load -i redis_5.0.0-image.tar.gz 进行加载,docker run -tid --name redis redis:5.0.0 进行运行。
docker-compose安装redis-sentinel集群(1主+2副+2哨兵)
docker制作自定义化的tomcat镜像,满足项目自定义需求,相关文章指导可参考https://blog.csdn.net/Ber_Bai/article/details/119960730?spm=1001.2014.3001.5501
在这个场景中,我们有一个针对 Redis 3.2 版本的自定义配置文件 `redis.conf`,该文件是为在 Docker 环境下调试 Redis 实例而设计的。下面将详细解释配置文件中的关键设置和它们在 Docker 容器中的作用。 1. **端口...
内容包括docker常用命令、docker部署sqlserver、mongodb、redis(集群)、mysql、nginx、zookeeper集群、xxl-job、nacos(集群)、rocketmq、sentinel、jenkins等服务;docker开启远程调用、导出日志等
redis的安装也是十分的简单,我们依然使用docker安装redis 1、在docker 仓库下载redis #在docker仓库搜索redis docker search redis #下载redis到本地仓库不加版本号默认是最新版 docker pull redis #查看下载好的...
文章【redis】docker安装redis 配置文件redis.conf,放入挂载的目录下。