Docker 用Dockerfile部署Apache网站,面试官版java面试小册

v0.1: digest: sha256:20337cdfd55de2cd1b87f796661535d6c97e6b837c03cb1390efe01a43cca342 size: 954

基于Alpine 编写Apache的Dockerfile(精简版)

================================================================================================

//创建apache服务的dockerfile文件目录

[root@localhost ~]# mkdir httpd/files -p

//上传源码包

[root@localhost ~]# ls httpd/files

apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.51.tar.gz

//项目结构

[root@localhost ~]# tree

.

|-- anaconda-ks.cfg

`-- httpd

|-- Dockerfile

`-- files

|-- apr-1.7.0.tar.gz

|-- apr-util-1.6.1.tar.gz

|-- httpd-2.4.51.tar.gz

`-- install.sh

2 directories, 6 files

//添加脚本权限

[root@localhost ~]# touch httpd/files/install.sh

[root@localhost ~]# chmod +x httpd/files/install.sh

[root@localhost ~]# ll httpd/files/install.sh

-rwxr-xr-x. 1 root root 1444 Dec 10 18:37 httpd/files/install.sh

//编写dockerfile

[root@localhost ~]# vim httpd/Dockerfile

[root@localhost ~]# cat httpd/Dockerfile

FROM alpine

LABEL MAINTAINER=‘1314444 123@qq.com’

#定义变量

ENV apr_version 1.7.0

ENV apr_util_version 1.6.1

ENV httpd_version 2.4.51

#环境变量

ENV PATH /usr/local/apache/bin:$PATH

#把需要安装apache的源码包传输到/tmp/下

COPY files /tmp/

#运行安装脚本(alpine这个系统不支持/bin/bash)

RUN /tmp/install.sh

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值