dockerfile的基本应用

配置解压目录

删除安装包

FROM hub.c.163.com/public/centos:6.7-tools

MAINTAINER wang@.com

 

ADD apache-tomcat-7.0.54.tar.gz /usr/src

ADD jdk-7u65-linux-x64.gz /usr/src

 

ENV JAVA_HOME /usr/src/jdk1.7.0_65

ENV PATH $JAVA_HOME/bin/$PATH

 

EXPOSE 8080

 

ENTRYPOINT /usr/src/apache-tomcat-7.0.54/bin/startup.sh && tailf /usr/src/apache-tomcat-7.0.54/logs/catalina.out

配置广播

使用dockerfile生成镜像

查询

使用tomcat镜像生成容器发布8080端口

查询

客户机访问测试

配置httpd

FROM hub.c.163.com/public/centos:6.7-tools

MAINTAINER wang@.com

 

RUN yum -y install httpd

 

RUN echo "www.benet.com" > /var/www/html/index.html

 

CMD ["httpd","-DFOREGROUND"]

 

配置镜像

查看

生成容器

查询

客户端访问测试

配置源代码安装nginx

FROM hub.c.163.com/public/centos:6.7-tools

MAINTAINER wang@.com

 

RUN rm -rf /etc/yum.repos.d/Centos-*

RUN wget -O /etc/yum.repos.d/Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

RUN yum -y install epel-release pcre-devel zlib-devel gcc

 

ADD nginx-1.6.0.tar.gz /usr/src/

RUN useradd -M -s /sbin/nologin nginx

 

WORKDIR /usr/src/nginx-1.6.0

 

RUN ./configure --user=nginx --prefix=/usr/local/nginx --with-http_stub_status_module && make && make install

RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf

 

ENV PATH /usr/local/nginx/sbin:$PATH

 

EXPOSE 80

 

CMD [ "nginx"]

配置容器

访问测试

源代码安装mysql

配置镜像

MAINTAINER lin.zhang@jbit.cn

 

RUN rm -rf /etc/yum.repos.d/Centos-*

RUN wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

RUN yum -y install epel-release ncurses-devel libstdc++-deve gcc-c++

 

RUN groupadd mysql

RUN useradd -M -s /sbin/nologin -g mysql mysql

 

ADD cmake-2.8.6.tar.gz /usr/src/

ADD mysql-5.5.22.tar.gz /usr/src/

 

WORKDIR /usr/src/cmake-2.8.6

RUN ./configure && gmake && gmake install

WORKDIR /usr/src/mysql-5.5.22

RUN cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_

CHARSETS=all -DSYSCONFDIR=/etc && make && make install

RUN chown -R mysql:mysql /usr/local/mysql/

RUN cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

RUN ln -s /usr/local/mysql/bin/* /usr/local/bin

RUN cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

RUN chmod u+x /etc/init.d/mysqld

RUN chkconfig --add mysqld

RUN chkconfig mysqld on

RUN /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

COPY mysqld.sh /usr/src/

RUN chmod +x /usr/src/mysqld.sh

EXPOSE 3306

CMD "/usr/src/mysqld.sh" && tail -f /dev/null

配置启动脚本

创建镜像

配置容器查看

查看是否运行

登录容器

设置密码登录mysql

配置访问权限

安装mysql客户端访问

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值