[root@localhost ~]# docker pull centos:8
8: Pulling from library/centos
a1d0c7532777: Pull complete
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:8
docker.io/library/centos:8
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 8 5d0da3dc9764 10 months ago 231MB
[root@localhost ~]# docker run -it --name httpd centos:8 /bin/bash
[root@96d95580f706 /]# cd /pos.d/
[root@pos.d]# rm -rf *
[root@pos.d]# curl -o /pos.po .po% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--100 2495 100 2495 0 0 10895 0 --:--:-- --:--:-- --:--:-- 10895
[root@pos.d]# ls
po
[root@pos.d]# yum clean all
Failed to set locale, defaulting to C.UTF-8
0 files removed
[root@pos.d]# yum makecache
Failed to set locale, defaulting to C.UTF-8
CentOS-8.5.2111 - Base - mirrors.ali 966 kB/s | 4.6 MB 00:04
CentOS-8.5.2111 - Extras - mirrors.a 58 kB/s | 10 kB 00:00
CentOS-8.5.2111 - AppStream - mirror 664 kB/s | 8.4 MB 00:13
Metadata cache created.
[root@pos.d]# sed -i -e '/mirrors.cloud.aliyuncs/d' -e '/mirrors.aliyuncs/d' /pos.po//开启一个新终端,不要退出退出容器会停止
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
96d95580f706 centos:8 "/bin/bash" 5 minutes ago Up 5 minutes httpd
//将源码包传到容器内
[root@localhost ~]# docker cp apr-1.7. httpd:/root
[root@localhost ~]# docker cp apr-util-1.6. httpd:/root
[root@localhost ~]# docker cp httpd-2.4. httpd:/root#安装依赖包
[root@96d95580f706 ~]# yum groups mark install 'Development Tools' -y
[root@96d95580f706 ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make vim
[root@96d95580f706 ~]# useradd -r -M -s /sbin/nologin apache
[root@96d95580f706 ~]# cd /root/
[root@96d95580f706 ~]# ls
anaconda-ks.cfg apr-1.7. httpd-2.4.
anaconda-post.log apr-util-1.6. original-ks.cfg
[root@96d95580f706 ~]# tar xf apr-1.7.
[root@96d95580f706 ~]# tar xf apr-util-1.6.
[root@96d95580f706 ~]# tar xf httpd-2.4.
[root@96d95580f706 ~]# cd apr-1.7.0
[root@96d95580f706 apr-1.7.0]# vim configure
//搜索下面这条 注释掉 或者删除
$RM "$cfgfile"
//编译apr
[root@96d95580f706 apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@96d95580f706 apr-1.7.0]# make && make install//编译apr-util
[root@96d95580f706 apr-1.7.0]# cd
[root@96d95580f706 ~]# cd apr-util-1.6.1
[root@96d95580f706 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@96d95580f706 apr-util-1.6.1]# make && make install//编译httpd
[root@96d95580f706 httpd-2.4.54]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
[root@96d95580f706 httpd-2.4.54]# make && make install
//环境变量
[root@96d95580f706 ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/apache.sh
[root@96d95580f706 ~]# source /etc/profile.d/apache.sh
[root@96d95580f706 ~]# which httpd
/usr/local/apache/bin/httpd
[root@96d95580f706 ~]# which apachectl
/usr/local/apache/bin/apachectl//软连接
[root@96d95580f706 ~]# ln -s /usr/local/apache/include/ /usr/include/apache
[root@96d95580f706 ~]# vim /etc/f
#ample:80 // 此行取消注释
[root@96d95580f706 ~]# apachectl start
[root@96d95580f706 ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
[root@96d95580f706 ~]# vi start.sh
[root@96d95580f706 ~]# cat start.sh
#!/bin/sh/usr/local/apache/bin/httpd
/bin/bash
[root@96d95580f706 ~]# chmod a+x start.sh
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
96d95580f706 centos:8 "/bin/bash" 59 minutes ago Up 59 minutes httpd
[root@localhost ~]# docker commit -p -c 'CMD ["/bin/bash","/start.sh"]' 96d95580f706 chenlang123/httpd:v0.1
sha256:0a876bd309f11221bf200f01606f3d31a75a5c2be51df23fa28ab9ad2d69904d
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
chenlang123/httpd v0.1 0a876bd309f1 23 seconds ago 744MB
centos 8 5d0da3dc9764 10 months ago 231MB
[root@localhost ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to to create one.
Username: chenlang123
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
Succeeded
//上传镜像
[root@localhost ~]# docker push chenlang123/httpd:v0.1
The push refers to repository [docker.io/chenlang123/httpd]
12da7c3b1809: Pushed
74ddd0ec08fa: Pushed
v0.1: digest: sha256:66462b764cd54659d99eae5c43000cab9b73d267ce275ba049d11877e38d0ab7 size: 742
[root@localhost ~]# docker pull chenlang123/httpd:v0.1
v0.1: Pulling from chenlang123/httpd
a1d0c7532777: Already exists
ea6686a0982d: Already exists
Digest: sha256:66462b764cd54659d99eae5c43000cab9b73d267ce275ba049d11877e38d0ab7
Status: Downloaded newer image for chenlang123/httpd:v0.1
docker.io/chenlang123/httpd:v0.1
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
chenlang123/httpd v0.1 0a876bd309f1 4 hours ago 744MB
centos 8 5d0da3dc9764 10 months ago 231MB
[root@localhost ~]# docker run -dit -p 80:80 --name web chenlang123/httpd:v0.1 /bin/bash
679e17935af96b5488f157064c11263358e710bb35517c1570acb92c72c03619
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:80 [::]:*
本文发布于:2024-01-30 16:06:07,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170660196821209.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |