首页 > 其他分享 >构建LNP镜像

构建LNP镜像

时间:2022-10-22 22:36:32浏览次数:41  
标签:LNP dev nginx 构建 ubuntu 镜像 php root rocky8

1、构建ubuntu-base环境

#10.0.0.28:
[root@rocky8 ubuntu_base]#vim Dockerfile
FROM ubuntu:20.04
LABEL maintainer="www.wang.org" version="ubuntu_base:v1.0"

RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

RUN apt update && \
apt -y install tree wget vim curl iproute2 tzdata zip unzip && \
rm -f /etc/localtime && \
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@rocky8 ubuntu_base]#docker build -t ubuntu_base:v1.0 .

2、基于ubuntu-base镜像构建php环境

#10.0.0.28:
[root@rocky8 ubuntu_php]#vim Dockerfile
FROM ubuntu_base:v1.0
LABEL maintainer="www.wang.org" version="ubuntu_php:v1.0"

ADD php-7.4.30.tar.gz /usr/local/src/

RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN apt update && \
apt -y install gcc make libssl-dev libxml2-dev libsqlite3-dev libcurl3-dev libxml2 sqlite3 pkg-config zlib1g-dev libonig-dev libkrb5-dev libssl-dev libbz2-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libfreetype-dev g++ libonig-dev libxslt-dev libzip-dev && \
cd /usr/local/src/php-7.4.30 && \
./configure --prefix=/apps/php74 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-zlib --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo && \
make && make install && \
useradd -r -u 888 nginx

COPY php.ini /usr/local/src/php-7.4.30/
COPY www.conf /apps/php74/etc/php-fpm.d/
COPY php-fpm.conf /apps/php74/etc/


[root@rocky8 ubuntu_php]#ls
Dockerfile php-7.4.30.tar.gz php-fpm.conf php.ini www.conf

[root@rocky8 ubuntu_php]#docker build -t ubuntu_php:v1.0 .

3、基于php镜像构建nginx镜像

#10.0.0.28:
[root@rocky8 ubuntu_nginx]#vim Dockerfile
FROM ubuntu_php:v1.0
LABEL maintainer="www.wang.org" version="ubuntu_nginx:v1.0"

ADD nginx-1.22.0.tar.gz /usr/local/src/

RUN apt update && \
apt install -y nfs-kernel-server nfs-common gcc openssh-server lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev unzip zip make
RUN cd /usr/local/src/nginx-1.22.0 && \
./configure --prefix=/apps/nginx && \
make && make install && \
ln -s /apps/nginx/sbin/nginx /usr/bin && \
mkdir /apps/nginx/conf/conf.d && \
rm -rf /usr/local/src/nginx-1.22.0/*

ADD nginx.conf /apps/nginx/conf/nginx.conf

RUN chown -R nginx.nginx /apps/nginx/

COPY run_nginx.sh /usr/local/sbin/

EXPOSE 80 443

CMD ["run_nginx.sh"]

[root@rocky8 ubuntu_nginx]#vim run_nginx.sh
/apps/php74/sbin/php-fpm
/apps/nginx/sbin/nginx -g "daemon off;"

[root@rocky8 ubuntu_nginx]#chmod +x run_nginx.sh

[root@rocky8 conf.d]#vim wordpress.wang.org.conf
server {
listen 80;
server_name wordpress.wang.org;
root /data/wordpress;
index index.php index.html index.htm;
location ~ \.php$|ping {
root /data/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

[root@rocky8 ubuntu_nginx]#docker build -t ubuntu_nginx:v1.0 .

[root@rocky8 data]#groupadd -r -g 888 nginx
[root@rocky8 data]#useradd -u 888 -g nginx -s /sbin/nologin -r nginx
[root@rocky8 data]#id nginx
uid=888(nginx) gid=888(nginx) groups=888(nginx)
[root@rocky8 data]#chmod -R nginx.nginx /data/wordpress/ #如果不给权限,wordpress连接数据会报无法写入的错误


[root@rocky8 conf.d]#docker run -it -d -p 80:80 --name wordpress -v /data/conf.d:/apps/nginx/conf/conf.d -v /data/wordpress:/data/wordpress ubuntu_nginx:v1.0

4、安装数据库

#10.0.0.28:
root@rocky8 ~]#docker pull mysql:8.0.30-oracle

[root@rocky8 ~]#docker run -d --name mysql --network container:wordpress -e MYSQL_ROOT_PASSWORD=123456 -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=123456 -v /data/mysql:/var/lib/mysql mysql:8.0.30-oracle

[root@rocky8 conf.d]#docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b5c7e672d29f mysql:8.0.30-oracle "docker-entrypoint.s…" 9 minutes ago Up 9 minutes mysql
15a1a13becbe ubuntu_nginx:v1.0 "run_nginx.sh" 12 minutes ago Up 12 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp, 443/tcp wordpress

5、实现harbor高可用

#10.0.0.101:
[root@ubuntu2004 ~]#bash install_harbor.sh
[root@ubuntu2004 ~]#vim /apps/harbor/harbor.yml
hostname: 10.0.0.101
[root@ubuntu2004 ~]#/apps/harbor/prepare

[root@ubuntu2004 ~]#vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://pgavrk5n.mirror.aliyuncs.com"],
"insecure-registries": ["10.0.0.101","10.0.0.102"]

}
[root@ubuntu2004 ~]#systemctl restart docker.service
[root@ubuntu2004 ~]#systemctl restart harbor.service


##10.0.0.102:
[root@ubuntu2004 ~]#bash install_harbor.sh
[root@ubuntu2004 ~]#vim /apps/harbor/harbor.yml
hostname: 10.0.0.102
[root@ubuntu2004 ~]#/apps/harbor/prepare

[root@ubuntu2004 ~]#vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://pgavrk5n.mirror.aliyuncs.com"],
"insecure-registries": ["10.0.0.101","10.0.0.102"]
}
[root@ubuntu2004 ~]#systemctl restart docker.service
[root@ubuntu2004 ~]#systemctl restart harbor.service


#浏览器分别登陆101和102设置:项目、目标和规则

构建LNP镜像_docker

构建LNP镜像_php_02

构建LNP镜像_nginx_03

构建LNP镜像_ubuntu_04

构建LNP镜像_docker_05

构建LNP镜像_docker_06

5-1、上传测试
[root@rocky8 ubuntu_nginx]#docker login 10.0.0.101
[root@rocky8 ubuntu_nginx]#docker tag ubuntu_nginx:v1.0 10.0.0.101/test/ubuntu_nginx:v1.0
[root@rocky8 ubuntu_nginx]#docker push 10.0.0.101/test/ubuntu_nginx:v1.0

构建LNP镜像_docker_07

构建LNP镜像_docker_08

标签:LNP,dev,nginx,构建,ubuntu,镜像,php,root,rocky8
From: https://blog.51cto.com/dayu/5786146

相关文章

  • CentOS部署Harbor镜像仓库
    欢迎访问我的GitHub这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos关于HarborHarbor是用于存储和分发Docker镜像的镜像仓库服务,相......
  • 镜像包
    1、qemu的大略参数的大略使用方法https://xuanxuanblingbling.github.io/ctf/tools/2020/04/16/qemu/2、debian的qemuqcow2直接加载包2.1)https://people.debian.org/~au......
  • SpringBoot微服务打包Docker镜像
    1.构建sprintboot项目2.打包应用3.编写dockerfileidea下载docker插件(可以高亮)4.构建镜像先把之前镜像都移除dockerrm-f$(dockerps-qa)在Linuxhome目......
  • docker删除镜像
    docker要删除镜像,先要删除依赖它的容器1.删除容器dockerps#查看正在运行的容器dockerps-a#查看所有容器dockerrmcontainer_id#删除容器2.删除镜像dockeri......
  • dremio 23 版本docker 镜像jdk 说明
    实际上dremio官方在232版本的relasenote中已经说明了关于jdk的处理,在看了最新docker镜像也可以印证此说明参考处理22版本的  23版本的  说明目......
  • CentOS 安装 Docker+ Aliyun 镜像
     1.使用一键安装命令curl-fsSLhttps://get.docker.com|bash-sdocker--mirrorAliyun  2.配置阿里云镜像,进入网站https://cr.console.aliyun.com/cn-ha......
  • docker和containerd清空所有镜像和容器 并释放空间
    文档说明:只记录关键有用的地方;docker清理dockersystemdf#占用存储空间,又没有用的容器dockerimages-aq-f'dangling=true'|xargsdockerrmi#删除所有d......
  • ​Win11 22H2【10月累积更新镜像下载+Moment 1更新】
    大版本号:22H2​内部版本号:22621.674​另外微软于本月已向部分用户推送Moment1更新【内部版本号是:22621.675】,它是一次小型的功能性更新,没有集成到镜像里,可手动安装升级。​......
  • 自动化测试 - php调用jenkins-api构建job
    背景:前一节搭建jenkins并创建了job任务后,用户可以在jenkins平台手动点击构建来执行pytest自动化任务,想实现一个从web界面去触发构建jenkins中的job任务,在这选择使用php来调......
  • Kubernetes镜像
    https://developer.aliyun.com/mirror/kubernetes点击查看代码apt-getupdate&&apt-getinstall-yapt-transport-httpscurlhttps://mirrors.aliyun.com/kubernete......