dockerfite创建镜像---INMP+wordpress

目录

搭建dockerfile---lnmp

创建nginx镜像

运行

创建数据库镜像

运行

​编辑

创建php镜像

运行


搭建dockerfile---lnmp

在192.168.10.201

服务IP地址
nginx 172.111.0.10 docker+nginx
mysql172.111.0.20docker+mysql
php172.111.0.30docker+php

创建nginx镜像

路径
vim /opt/nginx/Dockerfile
-------------------------------------------------------------------------------------------

FROM centos:7
RUN yum -y install gcc pcre-devel openssl-devel zlib-devel openssl openssl-devel
ADD nginx-1.22.0.tar.gz /usr/local/src/
RUN useradd -M -s /sbin/nologin nginx
WORKDIR /usr/local/src/nginx-1.22.0
RUN ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module && make -j 4 && make install
ENV PATH /usr/local/nginx/sbin:$PATH
COPY nginx.conf /usr/local/nginx/conf/
ADD wordpress-6.4.2-zh_CN.tar.gz /usr/local/nginx/html
RUN chmod -R 777 /usr/local/nginx/html
EXPOSE 80
VOLUME ["/usr/local/nginx/html/"]
CMD ["/usr/local/nginx/sbin/nginx","-g","daemon off;"]

-------------------------------------------------------------------------------------------
位置
vim /opt/nginx/nginx.conf
-----------------------------------------------------------------------------------------

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        charset utf-8;
        location / {
            root   html;
            index  index.html index.php;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            root           html;
            fastcgi_pass   172.111.0.30:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }
}
}

-----------------------------------------------------------------------------------------

运行

1、创建nginx镜像
docker build -t nginx1:lnmp .

2、创建自定义网络
docker network create --subnet=172.111.0.0/16 --opt "com.docker.network.bridge.name"="docker1" mynetwork

3、创建并启动容器
docker run -itd --name nginx1 -p 80:80 -v /opt/nginx:/opt/nginxlogs --net mynetwork --ip 172.111.0.10 nginx:lnmp

创建数据库镜像

vim /opt/mysql/Dockerfile
-----------------------------------------------------------------------------------------

FROM centos:7
RUN yum -y install ncurses ncurses-devel bison cmake pcre-devel zlib-devel gcc gcc-c++ make && useradd -M -s /sbin/nologin mysql
ADD mysql-boost-5.7.20.tar.gz /usr/local/src/
WORKDIR /usr/local/src/mysql-5.7.20/
RUN cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8  \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost \
-DWITH_SYSTEMD=1 && make -j 6 && make install
COPY my.cnf /etc/my.cnf
EXPOSE 3306  
RUN chown -R mysql:mysql /usr/local/mysql && chown mysql:mysql /etc/my.cnf
WORKDIR /usr/local/mysql/bin/
RUN ./mysqld \
--initialize-insecure \
--user=mysql \  
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data && cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/ && systemctl enable mysqld
ENV PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
VOLUME ["/usr/local/mysql"]
ENTRYPOINT ["/usr/sbin/init"]

-----------------------------------------------------------------------------------------
vim /opt/mysql/my.cnf
-----------------------------------------------------------------------------------------

[client]
port = 3306
socket=/usr/local/mysql/mysql.sock

[mysqld]
user = mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port = 3306
character-set-server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
bind-address = 0.0.0.0
skip-name-resolve
max_connections=2048
default-storage-engine=INNODB
max_allowed_packet=16M
server-id = 1
general_log=ON
general_log_file=/usr/local/mysql/data/mysql_general.log

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

-----------------------------------------------------------------------------------------

运行

1、创建mysql镜像
docker build -t mysql:lnmp .

2、创建并启动容器
docker run -itd --name mysql -p 3306:3306 --privileged -v /opt/mysql1:/opt/mysql --net mynetwork --ip 172.111.0.20 mysql:lnmp

3、进入数据库
mysql -u root -p

4、创建数据库
create database wordpress;

5、赋权
grant all privileges on wordpress.* to 'wordpress'@'%' identified by '123456';
grant all privileges on *.* to 'root'@'%' identified by '123456';
flush privileges;

创建php镜像

vim /opt/php/Dockerfile
-----------------------------------------------------------------------------------------

FROM centos:7
RUN yum -y install gd \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel \
gcc gcc-c++ make pcre-devel && useradd -M -s /sbin/nologin nginx
ADD php-7.1.10.tar.bz2 /usr/local/src
WORKDIR /usr/local/src/php-7.1.10
RUN ./configure \
--prefix=/usr/local/php \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip && make -j 4 && make install
ENV PATH /usr/local/php/bin:/usr/local/php/sbin:$PATH
COPY php.ini /usr/local/php/lib
COPY php-fpm.conf /usr/local/php/etc/
COPY www.conf /usr/local/php/etc/php-fpm.d/
EXPOSE 9000
ENTRYPOINT ["/usr/local/php/sbin/php-fpm","-F"]

-----------------------------------------------------------------------------------------
vim /opt/php/php-fpm.conf
-----------------------------------------------------------------------------------------

;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr/local/php). This prefix can be dynamically changed by using the
; '-p' argument from the command line.

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /usr/local/php/var
; Default Value: none
pid = run/php-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; into a local file.
; Note: the default prefix is /usr/local/php/var
; Default Value: log/php-fpm.log
;error_log = log/php-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated.  This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; The maximum number of processes FPM will fork. This has been designed to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lowest priority)
; Note: - It will only work if the FPM master process is launched as root
;       - The pool process will inherit the master process priority
;         unless specified otherwise
; Default Value: no set
; process.priority = -19

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select     (any POSIX os)
; - poll       (any POSIX os)
; - epoll      (linux >= 2.5.44)
; - kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll  (Solaris >= 7)

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select     (any POSIX os)
; - poll       (any POSIX os)
; - epoll      (linux >= 2.5.44)
; - kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll  (Solaris >= 7)
; - port       (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll

; When FPM is built with systemd integration, specify the interval,
; in seconds, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options.  The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr/local/php otherwise
include=/usr/local/php/etc/php-fpm.d/*.con
vim /opt/php/php.ini
-----------------------------------------------------------------------------------------

; reattach to the shared memory (for Windows only). Explicitly enabled file
; cache is required.
;opcache.file_cache_fallback=1

; Enables or disables copying of PHP code (text segment) into HUGE PAGES.
; This should improve performance, but requires appropriate OS configuration.
;opcache.huge_code_pages=0

; Validate cached file permissions.
;opcache.validate_permission=0

; Prevent name collisions in chroot'ed environment.
;opcache.validate_root=0

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =

[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
;openssl.cafile=

; If openssl.cafile is not specified or if the CA file is not found, the
; directory pointed to by openssl.capath is searched for a suitable
; certificate. This value must be a correctly hashed certificate directory.
; Most users should not specify a value for this directive as PHP will
; attempt to use the OS-managed cert stores in its absence. If specified,
; this value may still be overridden on a per-stream basis via the "capath"
; SSL stream context option.
;openssl.capath=

; Local Variables:
; tab-width: 4
; End:

-----------------------------------------------------------------------------------------
vim /opt/php/www.conf
-----------------------------------------------------------------------------------------

; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; execute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5 .php7

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'.
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr/local/php)

; Default Value: nothing is defined by default except the values in php.ini and
;                specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

-----------------------------------------------------------------------------------------

运行

1、创建php镜像
docker build -t php:lnmp .

2、创建并启动容器
docker run -itd --name php -p 9000:9000 --volumes-from nginx1 --volumes-from mysql --net mynetwork --ip 172.111.0.30 php:lnmp

登录页面

http://192.168.10.201:1314/wordpress/wp-admin/setup-config.php

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/248159.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

python基本数据类型(一)-字符串

1.字符串 字符串就是一系列字符,在Python中,用引号括起的都是字符串,其中的引号可以是单引号,也可以是双引号,如下所示: "This is a string." This is also a string.这种灵活性让你能够在字符…

【产品经理】产品增效项目落地,项目反哺产品成长

产品和项目是相辅相成的关系,产品的规范、成熟,为项目的快速落地提供支撑,项目的落地反哺产品,促进产品的成长成熟。 软件工程的初期是,我们需要什么,就立项项目,通过项目实现需要。 随着项目的…

用实例域代替序数

在Java中,枚举类型的ordinal()方法返回枚举常量的序数(即其在枚举声明中的位置)。在某些情况下,使用实例域(instance field)代替序数可能更加安全和易读。以下是一个示例,演示如何使用实例域代替…

低代码开发如何快速构建AI应用

随着人工智能(AI)的快速发展,越来越多的企业和开发者开始意识到AI在业务和应用中的重要性。然而,AI应用的开发通常被认为是复杂和耗时的过程,需要大量的编码和数据科学知识。为了解决这个问题,低代码开发平…

图片转HTML-screenshot-to-code

Github地址 https://github.com/abi/screenshot-to-code 在线站 Screenshot to Code 简介 这是一个基于GPT4开发的一个工具站,它可以基于截图生成站点代码,生成速度快且准确。

Linux-----2、虚拟机安装Linux

# 虚拟机安装Linux # 一、学习环境介绍 # 1、虚拟机概述 1、什么是虚拟机软件? 虚拟机软件,有些时候想模拟出一个真实的电脑环境,碍于使用真机安装代价太大,因此而诞生的一款可以模拟操作系统运行的软件。 虚拟机软件目前有2…

DSP定时器0笔记

首先了解开发板TMS320f28335是150Mhz的频率 定时器结构图和概要 定时器0对应的中断是TINT0 大概是这样,时钟sysclkout 进入和TCR控制时钟进入 ,经过标定计数器(stm32的预分频),标定器挂这自动装载寄存器&#xff0c…

Unity中实现ShaderToy卡通火(移植篇)

文章目录 前言一、准备好我们的后处理基础脚本1、C#:2、Shader: 二、开始逐语句对ShaderToy进行转化1、首先,找到我们的主函数 mainImage2、其余的方法全部都是在 mainImage 函数中调用的方法3、替换后的代码(已经没报错了,但是效…

基于ssm旅游网站的设计与实现论文

摘 要 现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本旅游网站就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息&#x…

rocketmq window测试小Demo 解决找不到或无法加载主类的问题

文章目录 rocketMQ启动1.下在相关的二进制文件2.配置环境变量3.启动NameServer4.启动broker5. MQ 启动!5.1 测试发送数据 6.关闭服务 rocketMQ启动 1.下在相关的二进制文件 下载地址,点击即达 2.配置环境变量 3.启动NameServer 在文件夹下执行cmd进…

嵌入式奇妙之旅:Python与树莓派编程深度探索

💂 个人网站:【 海拥】【神级代码资源网站】【办公神器】🤟 基于Web端打造的:👉轻量化工具创作平台💅 想寻找共同学习交流的小伙伴,请点击【全栈技术交流群】 在这个数字化的时代,嵌入式系统的应…

如何理解 RPC 远程服务调用?

本文主要讲解 RPC 远程服务调用相关的知识。 RPC 远程服务调用是分布式服务架构的基础,无论微服务设计上层如何发展,讨论服务治理都绕不开远程服务调用,那么如何理解 RPC、有哪些常见的 RPC 框架、实现一款 RPC 框架需要哪些技术呢&#xff…

3D点云广义零样本分类的递归循环对比生成网络笔记

1 Title Contrastive Generative Network with Recursive-Loop for 3D point cloud generalized zero-shot classification(Yun Hao, Yukun Su, Guosheng Lin, Hanjing Su, Qingyao Wu)【Pattern Recognition】 2 Conclusion This work aims to facilitate research on 3D poi…

web微服务规划

一、背景 通过微服务来搭建web系统,就要对微服务进行规划,包括服务的划分,每个服务和数据库的命名规则,服务用到的端口等。 二、微服务划分 1、根据业务进行拆分 如: 一个购物系统可以将微服务拆分为基础中心、会员…

卸载Postman?这款IDEA插件真可以!

Postman是大家最常用的API调试工具,那么有没有一种方法可以不用手动写入接口到Postman,即可进行接口调试操作?今天给大家推荐一款IDEA插件:Apipost Helper,写完代码就可以调试接口并一键生成接口文档!而且还…

群晖7.2使用Docker安装容器魔方结合内网穿透实现远程访问

最近,我发现了一个超级强大的人工智能学习网站。它以通俗易懂的方式呈现复杂的概念,而且内容风趣幽默。我觉得它对大家可能会有所帮助,所以我在此分享。点击这里跳转到网站。 文章目录 1. 拉取容器魔方镜像2. 运行容器魔方3. 本地访问容器魔…

注意std::shared_ptr的循环引用

指针智能是RAII的思想的具体体现。利用对象生命周期来管理资源。 在C11中,引入shared_ptr、weak_ptr和unique_ptr。 share_ptr是一个能有效解决赋值和拷贝构造的引用技术。 std::shared_ptr通过引用计数的方式来管理对象的生命周期,但是如果两个对象互…

老卫带你学---leetcode刷题(29. 两数相除)

29. 两数相除 问题 给你两个整数,被除数 dividend 和除数 divisor。将两数相除,要求 不使用 乘法、除法和取余运算。 整数除法应该向零截断,也就是截去(truncate)其小数部分。例如,8.345 将被截断为 8 &…

动态面板简介以及ERP原型图案列

动态面板简介以及ERP原型图案列 1.Axure动态面板简介2.使用Axure制作ERP登录界面3.使用Asure完成左侧菜单栏4.使用Axuer完成公告栏5.使用Axuer完成左边侧边栏 1.Axure动态面板简介 在Axure RP中,动态面板是一种强大的交互设计工具,它允许你创建可交互的…

致远互联FE协作办公平台 editflow_manager.jsp 存在SQL注入漏洞

文章目录 产品简介漏洞概述指纹识别漏洞利用修复建议 产品简介 致远互联FE协作办公平台是一个专注于协同管理软件领域的数智化运营平台及云服务提供商。平台旨在为企业提供数字化转型和升级的解决方案,特别是针对大中型政府和企业客户。平台的主要特点包括开放共享…