Dockerfile部署LNMP

这篇具有很好参考价值的文章主要介绍了Dockerfile部署LNMP。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。


一、项目模拟

1. 项目环境

公司在实际的生产环境中,需要使用 Docker 技术在一台主机上创建 LNMP 服务并运行 Wordpress 网站平台。然后对此服务进行相关的性能调优和管理工作。
所有安装包下载:

wget http://101.34.22.188/lnmp_wordpress/mysql-boost-5.7.20.tar.gz
wget http://101.34.22.188/lnmp_wordpress/nginx-1.12.0.tar.gz
wget http://101.34.22.188/lnmp_wordpress/php-7.1.10.tar.bz2
wget http://101.34.22.188/lnmp_wordpress/wordpress-4.9.4-zh_CN.tar.gz
> 或者
wget -r -np http://101.34.22.188/lnmp_wordpress/

2. 服务器环境

容器 操作系统 IP地址 主要软件
nginx CentOS 7.9 x86_64 172.20.0.10 Docker-Nginx
mysql Centos 7.9 x86_64 172.20.0.20 Docker-Mysql
php Centos 7.9 x86_64 172.20.0.30 Docker-php

3. 任务需求

(1)使用 Docker 构建 LNMP 环境并运行 Wordpress 网站平台。

(2)限制 Nginx 容器最多使用 500MB 的内存和 1G 的 Swap。

(3)限制 Mysql 容器写 /dev/sda 的速率为 10 MB/s。

(4)将所有容器进行快照,然后将 Docker 镜像打包成 tar 包备份到本地。

二、Linux 系统基础镜像

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled
[root@localhost ~]# docker pull centos:7
#从公有仓库中下载 centos7 作为系统基础镜像
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
centos       7         eeb6ee3f44bd   4 weeks ago   204MB

三、Nginx

1. 建立工作目录

[root@localhost ~]# mkdir /opt/nginx
[root@localhost ~]# cd /opt/nginx
[root@localhost nginx]# rz -E
rz waiting to receive.
#上传 nginx 安装包 nginx-1.12.0.tar.gz
[root@docker nginx]# rz -E
rz waiting to receive.
#上传 wordpress 服务包 wordpress-4.9.4-zh_CN.tar.gz

2. 编写 Dockerfile 脚本

[root@localhost nginx]# vim Dockerfile
 
FROM centos:7
MAINTAINER this is nginx image <lnmp>
RUN yum -y install pcre-devel zlib-devel gcc gcc-c++ make;useradd -M -s /sbin/nologin nginx
ADD nginx-1.12.0.tar.gz /usr/local/src/
WORKDIR /usr/local/src/nginx-1.12.0
RUN ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module;make -j 4 && make install
ENV PATH /usr/local/nginx/sbin:$PATH
ADD nginx.conf /usr/local/nginx/conf/
ADD wordpress-4.9.4-zh_CN.tar.gz /usr/local/nginx/html
RUN chmod 777 -R /usr/local/nginx/html/
EXPOSE 80
VOLUME [ "/usr/local/nginx/html/" ]
CMD [ "/usr/local/nginx/sbin/nginx","-g","daemon off;" ]

Dockerfile部署LNMP,docker

3. 准备 nginx.conf 配置文件

[root@localhost nginx]# ls
Dockerfile  nginx-1.12.0.tar.gz  nginx.conf  wordpress-4.9.4-zh_CN.tar.gz
[root@localhost nginx]# vim 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.20.0.30:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}

Dockerfile部署LNMP,docker

4. 生成镜像

[root@localhost nginx]# docker build -t nginx:lnmp .
[root@localhost opt]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
nginx        lnmp      75e7f79716f9   About a minute ago   598MB
centos       7         eeb6ee3f44bd   23 months ago        204MB

Dockerfile部署LNMP,docker
Dockerfile部署LNMP,docker

5. 创建自定义网络

[root@localhost opt]# docker network create --subnet=172.20.0.0/16 --opt "com.docker.network.bridge.name"="docker1" mynetwork
38cc84c3a75271eb21606134c5e800f926a4848942c1bcab95f8b904f725d056
[root@localhost opt]# docker network ls
NETWORK ID     NAME        DRIVER    SCOPE
8a8a1c1be934   bridge      bridge    local
fe322e887e76   host        host      local
38cc84c3a752   mynetwork   bridge    local
b7aebed13475   none        null      local
[root@localhost opt]# ifconfig 
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:7dff:fe9e:755b  prefixlen 64  scopeid 0x20<link>
        ether 02:42:7d:9e:75:5b  txqueuelen 0  (Ethernet)
        RX packets 18511  bytes 753089 (735.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 19159  bytes 183308403 (174.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.20.0.1  netmask 255.255.0.0  broadcast 172.20.2

Dockerfile部署LNMP,docker

6. 启动镜像容器

[root@localhost opt]#  docker run -d --name nginx -p 80:80 -m 500m --memory-swap 1g --net mynetwork --ip 172.20.0.10 nginx:lnmp
d757572aa5869d967ab02988f70881d62ba409c731ab8417658aa1d46e662b43
[root@localhost nginx]# docker ps
CONTAINER ID   IMAGE        COMMAND                  CREATED         STATUS         PORTS                               NAMES
24cbedd7982b   nginx:lnmp   "/usr/local/nginx/sb…"   4 seconds ago   Up 3 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   nginx

······


[root@localhost nginx]# docker inspect nginx
 "Networks": {
                "mynetwork": {
                    "IPAMConfig": {
                        "IPv4Address": "172.20.0.10"


Dockerfile部署LNMP,docker
Dockerfile部署LNMP,dockerDockerfile部署LNMP,docker

7. 验证 nginx

[root@localhost nginx]# curl http://192.168.10.23:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
 
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
 
<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Dockerfile部署LNMP,docker
Dockerfile部署LNMP,docker

三、Mysql

1. 建立工作目录

[root@localhost nginx]# mkdir /opt/mysql
[root@localhost nginx]# cd /opt/mysql/
[root@localhost mysql]# rz -E
rz waiting to receive.
#传入mysql安装包mysql-boost-5.7.20.tar.gz

2. 编写 Dockerfile

[root@localhost mysql]# vim Dockerfile 
 
FROM centos:7
MAINTAINER this is mysql image <lnmp>
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 -j4;make install
ADD 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" ]
CMD ["/usr/sbin/init"]

Dockerfile部署LNMP,docker

3. 准备 my.cnf 文件

[root@localhost mysql]# vim 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
 
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


Dockerfile部署LNMP,docker

4. 生成镜像

[root@docker mysql]# docker build -t mysql:lnmp .
[root@localhost mysql]# docker images                           
REPOSITORY   TAG       IMAGE ID       CREATED              SIZE 
mysql        lnmp      38643f763f7f   About a minute ago   10.1GB
nginx        lnmp      75e7f79716f9   38 minutes ago       598MB
centos       7         eeb6ee3f44bd   23 months ago        204MB

Dockerfile部署LNMP,docker
Dockerfile部署LNMP,docker

5. 启动镜像容器

[root@localhost mysql]# docker run --name=mysql -d --privileged --device-write-bps /dev/sda:10M -v /usr/local/mysql --net mynetwork --ip 172.20.0.20 mysql:lnmp
0a4ad94e00e8583c9f3385e7b024f89a0536aaef2989a2513d50086a5a130e36
[root@localhost mysql]# docker ps -a
CONTAINER ID   IMAGE        COMMAND                   CREATED          STATUS          PORTS                               NAMES
0a4ad94e00e8   mysql:lnmp   "/usr/sbin/init"          21 seconds ago   Up 16 seconds   3306/tcp                            mysql
d757572aa586   nginx:lnmp   "/usr/local/nginx/sb…"   36 minutes ago   Up 36 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp   nginx

Dockerfile部署LNMP,docker

6. 验证 mysql

[root@localhost mysql]# docker exec -it mysql bash
[root@0a4ad94e00e8 bin]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: activating (start) since Sun 2023-08-20 10:07:51 UTC; 1min 40s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 75 ExecStart=/usr/local/mysql/bin/mysqld --daemonize --pid-file=/usr/local/mysql/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 53 ExecStartPre=/usr/local/mysql/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
   CGroup: /docker/0a4ad94e00e8583c9f3385e7b024f89a0536aaef2989a2513d50086a5a130e36/system.slice/mysqld.service
           └─84 /usr/local/mysql/bin/mysqld --daemonize --pid...

Dockerfile部署LNMP,docker

四、Php

1. 建立工作目录

[root@localhost  mysql]# mkdir ../php
[root@localhost  mysql]# cd ../php/
[root@localhost  php]# rz -E
rz waiting to receive.
#传入php安装包php-7.1.10.tar.bz2

Dockerfile部署LNMP,docker

2. 编写 Dockerfile 脚本

[root@localhost php]# vim Dockerfile 
 
FROM centos:7
MAINTAINER this is php image <lnmp>
RUN yum install -y 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
ADD php.ini     /usr/local/php/lib/
ADD php-fpm.conf /usr/local/php/etc/
ADD www.conf /usr/local/php/etc/php-fpm.d/
EXPOSE 9000
CMD /usr/local/php/sbin/php-fpm -F

Dockerfile部署LNMP,docker

3. 准备 php.ini、php-fpm.conf、www.conf 配置文件

3.1 php.ini

该配置文件模板位于安装目录的 php-7.1.10/php.ini-development 位置

[root@localhost php]# vim php.ini
 
#939行,取消注释,修改
date.timezone = Asia/Shanghai
#1170行,修改
mysqli.default_socket = /usr/local/mysql/mysql.sock
[root@localhost php]# egrep -v "^;" php.ini | egrep -v "^$"
[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = On
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
[Date]
date.timezone = Asia/Shanghai
[filter]
[iconv]
[intl]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket = /usr/local/mysql/mysql.sock
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = On
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
[Assertion]
zend.assertions = 1
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[mcrypt]
[dba]
[opcache]
[curl]
[openssl]

Dockerfile部署LNMP,dockerDockerfile部署LNMP,docker
Dockerfile部署LNMP,docker
Dockerfile部署LNMP,docker
Dockerfile部署LNMP,docker
Dockerfile部署LNMP,docker
Dockerfile部署LNMP,docker

3.2 php-fpm.conf

该配置文件位于 /usr/local/php/etc/php-fpm.conf.default

[root@localhost php]# vim php-fpm.conf 
 
#17行,删除注释符号“;”
pid = run/php-fpm.pid
[root@localhost php]# egrep -v "^;" php-fpm.conf | egrep -v "^$"
[global]
pid = run/php-fpm.pid
include=/usr/local/php/etc/php-fpm.d/*.conf

Dockerfile部署LNMP,docker

3.3 www.conf

该配置文件位于 usr/local/php/etc/php-fpm.d/www.conf.default

[root@localhost php]# vim www.conf 
 
#23、24行,修改用户和组
user = nginx
group = nginx
#36行,修改监听IP和端口为容器IP:9000端口
listen = 172.20.0.30:9000
[root@localhost php]# egrep -v "^;" www.conf | egrep -v "^$"
[www]
user = nginx
group = nginx
listen = 172.20.0.30:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

Dockerfile部署LNMP,docker

4. 生成镜像

[root@localhost  php]# docker build -t php:lnmp .
[root@localhost php]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
php          lnmp      7724c46010cf   35 seconds ago   1.35GB
mysql        lnmp      38643f763f7f   18 minutes ago   10.1GB
nginx        lnmp      75e7f79716f9   55 minutes ago   598MB
centos       7         eeb6ee3f44bd   23 months ago    204MB

Dockerfile部署LNMP,dockerDockerfile部署LNMP,docker

5. 启动镜像容器

[root@localhost php]# docker run -itd --name php --net mynetwork --ip 172.20.0.30 -p 9000:9000 --volumes-from nginx --volumes-from mysql php:lnmp
c2c44fc8ef7481810a888b069d58689da56b9971386da132fdb26742327cb76d
[root@localhost php]# docker ps
CONTAINER ID   IMAGE        COMMAND                   CREATED          STATUS          PORTS                                       NAMES
c2c44fc8ef74   php:lnmp     "/bin/sh -c '/usr/lo…"   7 seconds ago    Up 7 seconds    0.0.0.0:9000->9000/tcp, :::9000->9000/tcp   php
0a4ad94e00e8   mysql:lnmp   "/usr/sbin/init"          18 minutes ago   Up 18 minutes   3306/tcp                                    mysql
d757572aa586   nginx:lnmp   "/usr/local/nginx/sb…"   54 minutes ago   Up 54 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp           nginx

Dockerfile部署LNMP,docker

6. 验证 php

[root@localhost php]# docker exec -it php bash
[root@c2c44fc8ef74 php-7.1.10]# ps -aux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.1 113028  7520 pts/0    Ss+  10:26   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nginx         7  0.0  0.0 113028  3772 pts/0    S+   10:26   0:00 php-fpm: pool www
nginx         8  0.0  0.0 113028  3772 pts/0    S+   10:26   0:00 php-fpm: pool www
root          9  0.0  0.0  11828  1884 pts/1    Ss   10:26   0:00 bash
root         23  0.0  0.0  51732  1728 pts/1    R+   10:26   0:00 ps -aux

Dockerfile部署LNMP,docker

五、启动 wordpress 服务

1. mysql 授权

进入 mysql 容器

[root@localhost nginx]# docker exec -it mysql bash
[root@0a4ad94e00e8 bin]# mysql -u root -p
Enter password: 
#初始密码为空
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
 
mysql> grant all privileges on wordpress.* to 'wordpress'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
 
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Dockerfile部署LNMP,docker
Dockerfile部署LNMP,docker

2. 浏览器访问测试

访问 http://192.168.40.105/wordpress/index.php
Dockerfile部署LNMP,docker
输入用户名和密码
Dockerfile部署LNMP,docker
现在安装
Dockerfile部署LNMP,docker
设置用户名和密码
Dockerfile部署LNMP,docker
点击 登录/登录成功
Dockerfile部署LNMP,docker

进入论坛http://192.168.40.105/wordpress/wp-admin/index.php
Dockerfile部署LNMP,docker
Dockerfile部署LNMP,docker文章来源地址https://www.toymoban.com/news/detail-660633.html


到了这里,关于Dockerfile部署LNMP的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 使用docker部署lnmp多站点

    1. 创建一个 Docker 网络 以便容器可以在同一网络上进行通信 2. 运行 MySQL 容器: 运行 MySQL 容器并将其连接到创建的网络。确保将 MySQL 的端口映射到宿主机上,以便您可以从宿主机访问数据库。 将mysql的配置和数据映射到宿主机中。 3. 运行 PHP 容器: 运行包含 PHP 代码的容器

    2024年02月08日
    浏览(39)
  • Docker容器与虚拟化技术:Docker compose部署LNMP

    目录    一、理论 1.LNMP架构 2.背景 3.Dockerfile部署LNMP 3.准备Nginx镜像 4.准备MySQL容器 5.准备PHP镜像 6.上传wordpress软件包 7.编写docker-compose.yml 8.构建与运行docker-compose 9.启动 wordpress 服务  10.浏览器访问 11.将运行中的 docker容器保存为 docker 镜像并保存到本地tar包 二、实验  1.环境

    2024年02月11日
    浏览(45)
  • Docker-Compose编排与部署(lnmp实例)

    第四阶段 时  间:2023年8月3日 参加人:全班人员 内  容: Docker-Compose编排与部署 目录 一、Docker Compose (一)概述 (二)Compose适用于所有环境: (三)docker-compose官方文档: (四)Compose的优点: (五)编排和部署 二、Compose原理 三、Compose应用案例 (一)安装docker-ce(

    2024年02月14日
    浏览(43)
  • 基于Dockerfile搭建LNMP

    目录 一、基础环境准备 1、环境前期准备  二、部署nginx(容器IP 为 172.18.0.10) 1、配置Dockerfile文件 2、配置nginx.conf文件 3、构建镜像、启动镜像 三、部署mysql 1、配置Dockerfile文件 2、配置my.conf文件 3、构建镜像、启动镜像 5、验证mysql 四、PHP部署 1、配置Dockerfile 2、配置相关文

    2024年02月08日
    浏览(37)
  • Dockerfile 创建镜像,构建LNMP+wordpress架构

    目录 一、Dockerfile 构建镜像 1.Dockerfile 构建 nginx镜像 1.1创建 nginx Dockerfile 目录 1.2编写 Dockerfile 文件 1.3构建nginx镜像 2.Dockerfile 构建 mysql 镜像 2.1创建 mysql Dockerfile 目录 2.2修改mysql配置文件 2.3编写 Dockerfile 文件 2.4构建mysql镜像 3.Dockerfile 构建 php 镜像 3.1创建 php Dockerfile 目录 3

    2024年02月15日
    浏览(83)
  • Dockerfile创建 LNMP 服务+Wordpress 网站平台

    公司在实际的生产环境中,需要使用 Docker 技术在一台主机上创建 LNMP 服务并运行 Wordpress 网站平台。然后对此服务进行相关的性能调优和管理工作。 所有安装包下载: wget http://101.34.22.188/lnmp_wordpress/mysql-boost-5.7.20.tar.gz wget http://101.34.22.188/lnmp_wordpress/nginx-1.12.0.tar.gz wget http:

    2024年02月12日
    浏览(40)
  • 【Docker】dockerfile部署conda并激活环境

    原文作者 :我辈李想 版权声明 :文章原创,转载时请务必加上原文超链接、作者信息和本声明。 在使用docker的过程中,跟着官方文档或各种教程都是很顺利的,在实际项目中,我碰到了一个docker部署conda镜像容器,实际程序是在虚拟环境slab中,不是base。项目是我从其他人

    2024年03月27日
    浏览(45)
  • docker从零开始(2)----应用部署/dockerfile

    通信 容器内的网络服务和外部机器不能直接通信 外部机器和宿主机可以直接通信 宿主机和机器可以直接通信 当容器中的网络服务需要被外部机器访问时,可以将容器中提供服务的端口映射到宿主机的端口上。外部机器访问宿主机的该端口,从而间接访问容器的服务。这种操

    2024年02月07日
    浏览(58)
  • docker+jenkins+dockerfile 自动化部署发布

    提示: 文章如有错误的地方请指出,以免误人子弟! 提示:以下是本篇文章正文内容,下面案例可供参考 下载镜像 下载maven maven 官网下载地址 或者使用命令下载 通过软件放到 linux 的目录下,这边放到Home目录下 解压 进到解压的目录下,创建项目的本地仓库文件夹并赋予读

    2024年02月05日
    浏览(47)
  • docker dockerfile部署contos7、nginx

    文件名:Dockerfile 运行dockerfile文件 启动nginx 安装php依赖 编译安装php 配置php相关文件 启动Php

    2024年02月15日
    浏览(45)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包