前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >云原生之使用docker部署httpd服务

云原生之使用docker部署httpd服务

原创
作者头像
江湖有缘
发布2023-01-27 21:28:12
7010
发布2023-01-27 21:28:12
举报
文章被收录于专栏:Linux成长之路Linux成长之路

一、检查系统版本

代码语言:shell
复制
[root@node ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

二、检查docker状态

1.检查docker版本

代码语言:shell
复制
[root@node ~]# docker -v
Docker version 20.10.17, build 100c701

2.检查docker状态

代码语言:shell
复制
[root@node ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2022-10-31 03:28:51 CST; 3 days ago
     Docs: https://docs.docker.com
 Main PID: 11884 (dockerd)
    Tasks: 45
   Memory: 3.4G
   CGroup: /system.slice/docker.service
           ├─11884 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           ├─89868 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8100 -container-ip 172.17.0.2 -container-port 8100
           ├─89875 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8100 -container-ip 172.17.0.2 -container-port 8100
           ├─95298 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3541 -container-ip 172.17.0.3 -container-port 3306
           └─95304 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 3541 -container-ip 172.17.0.3 -container-port 3306

Nov 03 11:28:02 node dockerd[11884]: time="2022-11-03T11:28:02.013519308+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Nov 03 11:28:02 node dockerd[11884]: time="2022-11-03T11:28:02.762364306+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Nov 03 11:28:03 node dockerd[11884]: time="2022-11-03T11:28:03.262033832+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Nov 03 11:28:03 node dockerd[11884]: time="2022-11-03T11:28:03.961466550+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Nov 03 11:28:05 node dockerd[11884]: time="2022-11-03T11:28:05.051145634+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Nov 03 11:28:06 node dockerd[11884]: time="2022-11-03T11:28:06.966059311+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Nov 03 11:28:10 node dockerd[11884]: time="2022-11-03T11:28:10.473723379+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Nov 03 11:28:17 node dockerd[11884]: time="2022-11-03T11:28:17.261643944+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Nov 03 11:28:30 node dockerd[11884]: time="2022-11-03T11:28:30.396312249+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Nov 03 11:28:56 node dockerd[11884]: time="2022-11-03T11:28:56.355217126+08:00" level=info msg="ignoring event" container=48b7ba756f8ee7...kDelete"
Hint: Some lines were ellipsized, use -l to show in full.

三、搜索httpd镜像

代码语言:shell
复制
[root@node ~]# docker search httpd
NAME                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
httpd                                The Apache HTTP Server Project                  4228      [OK]       
centos/httpd-24-centos7              Platform for running Apache httpd 2.4 or bui…   44                   
centos/httpd                                                                         35                   [OK]
arm32v7/httpd                        The Apache HTTP Server Project                  11                   
solsson/httpd-openidc                mod_auth_openidc on official httpd image, ve…   2                    [OK]
clearlinux/httpd                     httpd HyperText Transfer Protocol (HTTP) ser…   2                    
hypoport/httpd-cgi                   httpd-cgi                                       2                    [OK]
dockerpinata/httpd                                                                   1                    
manageiq/httpd                       Container with httpd, built on CentOS for Ma…   1                    [OK]
publici/httpd                        httpd:latest                                    1                    [OK]
inanimate/httpd-ssl                  A play container with httpd, ssl enabled, an…   1                    [OK]
dariko/httpd-rproxy-ldap             Apache httpd reverse proxy with LDAP authent…   1                    [OK]
nnasaki/httpd-ssi                    SSI enabled Apache 2.4 on Alpine Linux          1                    
lead4good/httpd-fpm                  httpd server which connects via fcgi proxy h…   1                    [OK]
centos/httpd-24-centos8                                                              1                    
patrickha/httpd-err                                                                  0                    
httpdss/archerysec                   ArcherySec repository                           0                    [OK]
e2eteam/httpd                                                                        0                    
amd64/httpd                          The Apache HTTP Server Project                  0                    
manageiq/httpd_configmap_generator   Httpd Configmap Generator                       0                    [OK]
httpdocker/kubia                                                                     0                    
paketobuildpacks/httpd                                                               0                    
ppc64le/httpd                        The Apache HTTP Server Project                  0                    
19022021/httpd-connection_test       This httpd image will test the connectivity …   0                    
manasip/httpd                                                                        0  

四、下载httpd镜像

代码语言:shell
复制
[root@node ~]# docker pull httpd:2.4
2.4: Pulling from library/httpd
a2abf6c4d29d: Already exists 
dcc4698797c8: Pull complete 
41c22baa66ec: Pull complete 
67283bbdd4a0: Pull complete 
d982c879c57e: Pull complete 
Digest: sha256:0954cc1af252d824860b2c5dc0a10720af2b7a3d3435581ca788dff8480c7b32
Status: Downloaded newer image for httpd:2.4
docker.io/library/httpd:2.4

五、创建httpd容器

1.创建数据目录

代码语言:shell
复制
[root@node ~]# mkdir -p /data/httpd
[root@node ~]# cd /data/httpd/

2.运行httpd容器

代码语言:shell
复制
[root@node httpd]# docker run -dit --name my-apache -p 8680:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4
6490b46fe58d5f9837e9fcbef8b1e7767048fffe6ce7480c3764ba43ae91f313

3.查看httpd容器状态

代码语言:shell
复制
[root@node httpd]# docker ps
CONTAINER ID   IMAGE               COMMAND                  CREATED          STATUS          PORTS                                                  NAMES
6490b46fe58d   httpd:2.4           "httpd-foreground"       27 seconds ago   Up 26 seconds   0.0.0.0:8680->80/tcp, :::8680->80/tcp                  my-apache

六、访问httpd服务

在这里插入图片描述
在这里插入图片描述

七、编辑index.html文件

1.编辑index.html文件

代码语言:shell
复制
[root@node httpd]# echo "aa-my-web-linux   ---"  > index.html
[root@node httpd]# ls
index.html

2.访问网站内容

代码语言:shell
复制
[root@node httpd]# curl 192.168.3.166:8680
aa-my-web-linux   ---

3.浏览器访问httpd服务

在这里插入图片描述
在这里插入图片描述

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、检查系统版本
  • 二、检查docker状态
    • 1.检查docker版本
      • 2.检查docker状态
      • 三、搜索httpd镜像
      • 四、下载httpd镜像
      • 五、创建httpd容器
        • 1.创建数据目录
          • 2.运行httpd容器
            • 3.查看httpd容器状态
            • 六、访问httpd服务
            • 七、编辑index.html文件
              • 1.编辑index.html文件
                • 2.访问网站内容
                  • 3.浏览器访问httpd服务
                  相关产品与服务
                  容器镜像服务
                  容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
                  领券
                  问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档