返回顶部
首页 > 资讯 > 服务器 >Docker下部署lnmp详细步骤
  • 655
分享到

Docker下部署lnmp详细步骤

2024-04-02 19:04:59 655人浏览 安东尼
摘要

目录拉取一个Centos镜像基于centos生成Nginx容器基于centos生成Mysql容器基于centos生成PHP容器制作镜像用新镜像创建lnmp容器测试拉取一个centos

拉取一个centos镜像


//下载centos镜像
[root@localhost ~]# Docker pull centos
Using default tag: latest
latest: Pulling from library/centos
a1d0c7532777: Pull complete 
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest

//查看镜像
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
centos       latest    5d0da3Dc9764   2 months aGo   231MB

基于centos生成nginx容器


//使用镜像启动容器并进入容器
[root@localhost ~]# docker run -it --name centos_nginx centos /bin/bash
[root@c193fcb41eae /]# yum -y install pcre-devel openssl openssl-devel gd-devel GCc gcc-c++ vim which make wget
[root@c193fcb41eae /]# yum -y groups mark install 'Development Tools'

//创建用户和组
[root@c193fcb41eae /]# useradd -r -M -s /sbin/nologin nginx

//创建日志存放目录
[root@c193fcb41eae /]# mkdir -p /var/log/nginx
[root@c193fcb41eae /]# chown -R nginx.nginx /var/log/nginx

//下载安装包以及解压
[root@c193fcb41eae /]# cd /usr/src/
[root@c193fcb41eae src]# wget Http://nginx.org/download/nginx-1.21.4.tar.gz
[root@c193fcb41eae src]# ls
debug  kernels  nginx-1.21.4.tar.gz
[root@c193fcb41eae src]# tar xf nginx-1.21.4.tar.gz 

//编译安装
[root@c193fcb41eae src]# cd nginx-1.21.4
[root@c193fcb41eae nginx-1.21.4]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log

[root@c193fcb41eae nginx-1.21.4]# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install 

[root@c193fcb41eae nginx-1.21.4]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@c193fcb41eae nginx-1.21.4]# . /etc/profile.d/nginx.sh
[root@c193fcb41eae nginx-1.21.4]# which nginx
/usr/local/nginx/sbin/nginx

[root@localhost ~]# docker exec -it nginx05  /bin/bash
[root@c193fcb41eae /]# ss -antl
State      Recv-Q Send-Q                                        Local Address:Port                                                       Peer Address:Port              
LISTEN     0      128                                                       *:80 

[root@c193fcb41eae /]# vi /usr/local/nginx/conf/nginx.conf
......
        location / {
            root   html;
            index index.php index.html index.htm;		#在45行中添加index.php
        }
......
        #取消location ~ .php$ 大括号前的注释(65~71)行
        location ~ \.php$ {
            root           /var/www/html;			#php测试页面目录
            fastcgi_pass   127.0.0.1:9000;			#在工作中这里要改为php服务器的地址
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;			#将/script改为$document_root
            include        fastcgi_params;
        }
        ......
daemon off;			#在前台运行


#下根目录下创建start.sh
[root@c193fcb41eae /]# cat >> start.sh <<EOF
#!/bin/bash
/usr/local/nginx/sbin/nginx
EOF

[ctrl]+q+p退出容器

[root@localhost ~]# docker ps
CONTaiNER ID   IMAGE              						 COMMAND               CREATED        STATUS          PORTS                   NAMES
c193fcb41eae   1314444/source_nginx:nginx-1.21.4         "/bin/bash"          24 hours ago    Up 30 minutes                           nginx05

基于centos生成mysql容器


//做mysql镜像并使用容器模式的网络
[root@localhost ~]# docker run -it --name mysql01 --network container:nginx05 centos:latest /bin/bash
[root@3367881fd446 /]#     #启动本地镜像centos 在里面安装MySQL --network container:nginx05 (以nginx05容器ID为共享网络)

//重新打开一个终端查看并上传mysql包
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND                  CREATED          STATUS          PORTS                                   NAMES
466e7f22d1f3   centos:latest                       "/bin/bash"              11 seconds ago   Up 10 seconds                                           mysql01		# mysql容器正运行
c193fcb41eae   1314444/source_nginx:nginx-1.21.4   "/usr/local/nginx/sb…"   9 hours ago      Up 34 minutes   0.0.0.0:8080->80/tcp, :::8080->80/tcp   nginx05

# mysql容器正运行
在这里插入代码片[root@localhost ~]# ls
anaconda-ks.cfg  mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# docker cp mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz mysql01:/usr/src

//MySQL容器下查看
[root@c193fcb41eae /]# ls /usr/src/
debug  kernels  mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz

////创建用户和组
[root@c193fcb41eae /]# useradd -r -M -s /sbin/nologin mysql
[root@c193fcb41eae /]# id mysql
uid=998(mysql) gid=996(mysql) groups=996(mysql)

//清理环境以及安装依赖包
[root@c193fcb41eae /]# yum clean all
[root@c193fcb41eae /]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel ncurses-compat-libs which nuMactl libaio

//解压
[root@c193fcb41eae /]# cd /usr/src/
[root@c193fcb41eae src]# tar xf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@c193fcb41eae src]# ls /usr/local/
bin  etc  games  include  lib  lib64  libexec  mysql-5.7.34-linux-glibc2.12-x86_64  sbin  share  src

//创建软连接
[root@c193fcb41eae src]# cd /usr/local/
[root@c193fcb41eae local]# ln -s mysql-5.7.34-linux-glibc2.12-x86_64 mysql
[root@c193fcb41eae local]# ls -l
total 0
drwxr-xr-x 2 root root   6 Nov  3  2020 bin
drwxr-xr-x 2 root root   6 Nov  3  2020 etc
drwxr-xr-x 2 root root   6 Nov  3  2020 games
drwxr-xr-x 2 root root   6 Nov  3  2020 include
drwxr-xr-x 2 root root   6 Nov  3  2020 lib
drwxr-xr-x 3 root root  17 Sep 15 14:17 lib64
drwxr-xr-x 2 root root   6 Nov  3  2020 libexec
lrwxrwxrwx 1 root root  35 Dec  3 16:18 mysql -> mysql-5.7.34-linux-glibc2.12-x86_64
drwxr-xr-x 9 root root 129 Dec  3 16:17 mysql-5.7.34-linux-glibc2.12-x86_64
drwxr-xr-x 2 root root   6 Nov  3  2020 sbin
drwxr-xr-x 5 root root  49 Sep 15 14:17 share
drwxr-xr-x 2 root root   6 Nov  3  2020 src

//修改属主属组
[root@c193fcb41eae local]# chown -R mysql.mysql /usr/local/mysql*
[root@c193fcb41eae local]# ls -l
total 0
drwxr-xr-x 2 root  root    6 Nov  3  2020 bin
drwxr-xr-x 2 root  root    6 Nov  3  2020 etc
drwxr-xr-x 2 root  root    6 Nov  3  2020 games
drwxr-xr-x 2 root  root    6 Nov  3  2020 include
drwxr-xr-x 2 root  root    6 Nov  3  2020 lib
drwxr-xr-x 3 root  root   17 Sep 15 14:17 lib64
drwxr-xr-x 2 root  root    6 Nov  3  2020 libexec
lrwxrwxrwx 1 mysql mysql  35 Dec  3 16:18 mysql -> mysql-5.7.34-linux-glibc2.12-x86_64
drwxr-xr-x 9 mysql mysql 129 Dec  3 16:17 mysql-5.7.34-linux-glibc2.12-x86_64
drwxr-xr-x 2 root  root    6 Nov  3  2020 sbin
drwxr-xr-x 5 root  root   49 Sep 15 14:17 share
drwxr-xr-x 2 root  root    6 Nov  3  2020 src

//添加环境变量
[root@c193fcb41eae local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@c193fcb41eae local]# source /etc/profile.d/mysql.sh
[root@c193fcb41eae local]# which mysql
/usr/local/mysql/bin/mysql

//头文件(include)、读取lib
[root@c193fcb41eae local]# ln -s /usr/local/mysql/include/ /usr/local/include/mysql
[root@c193fcb41eae local]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@c193fcb41eae local]# ldconfig

//创建数据存放目录
[root@c193fcb41eae local]# mkdir -p /opt/data
[root@c193fcb41eae local]# chown -R mysql.mysql /opt/data/
[root@c193fcb41eae local]# ls -l /opt/data/
total 0

//初始化数据库
[root@c193fcb41eae local]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/opt/data
2021-12-03T16:29:44.502079Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-12-03T16:29:44.673278Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-12-03T16:29:44.703121Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-12-03T16:29:44.759550Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 395770aa-5456-11ec-a2ae-0242ac110003.
2021-12-03T16:29:44.761730Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-12-03T16:29:45.276899Z 0 [Warning] CA certificate ca.pem is self signed.
2021-12-03T16:29:45.631478Z 1 [Warning] root@localhost is created with an empty passWord ! Please consider switching off the --initialize-insecure option.

//生成配置文件
[root@c193fcb41eae local]# cat > /etc/my.cnf <<EOF
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
Socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
EOF

//修改
[root@c193fcb41eae local]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /usr/local/mysql/support-files/mysql.server
[root@c193fcb41eae local]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /usr/local/mysql/support-files/mysql.server
[root@c193fcb41eae local]# 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@c193fcb41eae local]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL.Logging to '/opt/data/c193fcb41eae.err'.
 SUCCESS! 
[root@c193fcb41eae local]# 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:*                                 
LISTEN            0                 80                                       *:3306                                  *:*  

//修改密码
[root@c193fcb41eae local]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34 MySQL CommUnity Server (GPL)

Copyright (c) 2000, 2021, oracle and/or its affiliates.

Oracle is a reGIStered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password = password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye

//测试登录
[root@c193fcb41eae local]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.34 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye

[root@c193fcb41eae src]# rm -rf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz

在初始化mysql5.7的时候,报以下错误


error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

//解决方法
yum -y install numactl libaio

基于centos生成php容器


//运行一个php容器和nginx共享网络
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND                  CREATED          STATUS             PORTS                                   NAMES
466e7f22d1f3   centos:latest                       "/bin/bash"              52 minutes ago   Up 3 minutes                                               mysql01
c193fcb41eae   1314444/source_nginx:nginx-1.21.4   "/usr/local/nginx/sb…"   10 hours ago     Up About an hour   0.0.0.0:8080->80/tcp, :::8080->80/tcp   nginx05

[root@localhost ~]# docker run -it --name php8 --network container:nginx05 centos:latest  /bin/bash		# 启动本地镜像centos 在里面安装php --network container:nginx05 (以nginx05容器ID为共享网络)
[root@c193fcb41eae /]# 

//重新打开一个终端查看正在运行的容器
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND                  CREATED          STATUS             PORTS                                   NAMES
22ce0738d9d7   centos:latest                       "/bin/bash"              28 seconds ago   Up 27 seconds                                              php8
466e7f22d1f3   centos:latest                       "/bin/bash"              54 minutes ago   Up 5 minutes                                               mysql01
c193fcb41eae   1314444/source_nginx:nginx-1.21.4   "/usr/local/nginx/sb…"   10 hours ago     Up About an hour   0.0.0.0:8080->80/tcp, :::8080->80/tcp   nginx05

//清理环境并安装epel源
[root@c193fcb41eae /]# yum clean all
[root@c193fcb41eae /]# yum -y install epel-release

//安装依赖包
[root@c193fcb41eae /]# yum install sqlite-devel libzip-devel libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel  libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel openldap-devel pcre-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel gcc gcc-c++ make which --allowerasing

[root@c193fcb41eae /]# yum -y install http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm

//打开另一个终端上传php包到容器内
[root@localhost ~]# ls
anaconda-ks.cfg  mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz  php-8.0.11.tar.gz
[root@localhost ~]# docker cp php-8.0.11.tar.gz 22ce0738d9d7:/usr/src/

//解压
[root@c193fcb41eae /]# ls /usr/src/
debug  kernels  php-8.0.11.tar.gz
[root@c193fcb41eae /]# cd /usr/src/
[root@c193fcb41eae src]# tar xf php-8.0.11.tar.gz -C /usr/local/
[root@c193fcb41eae src]# cd /usr/local/
[root@c193fcb41eae local]# ls
bin  etc  games  include  lib  lib64  libexec  php-8.0.11  sbin  share  src

//编译并安装
[root@c193fcb41eae local]# cd php-8.0.11/
[root@c193fcb41eae php-8.0.11]# ./configure --prefix=/usr/local/php8  \
--with-config-file-path=/etc \
--enable-fpm \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-openssl \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif  \
--enable-ftp \
--enable-gd \
--with-jpeg \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix &&
make && make install

//添加环境变量
[root@c193fcb41eae php-8.0.11]# echo 'export PATH=/usr/local/php8/bin:$PATH' > /etc/profile.d/php.sh
[root@c193fcb41eae php-8.0.11]# source /etc/profile.d/php.sh
[root@c193fcb41eae php-8.0.11]# which php
/usr/local/php8/bin/php

//配置php-fpm文件
[root@c193fcb41eae php-8.0.11]# \cp php.ini-production /etc/php.ini
[root@c193fcb41eae php-8.0.11]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@c193fcb41eae php-8.0.11]# chmod +x /etc/init.d/php-fpm
[root@c193fcb41eae php-8.0.11]# cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf
[root@c193fcb41eae php-8.0.11]# cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf
[root@c193fcb41eae /]# mkdir -p /var/www/html
[root@c193fcb41eae /]#  cat > /var/www/html/index.php <<EOF
<?php
   phpinfo();
?>
EOF

[root@c193fcb41eae /]# vi /usr/local/php8/etc/php-fpm.conf
daemonize = no   #取消注释并设置daemonize = no,让php在前台运行

[root@c193fcb41eae /]# rm -rf /usr/src/php-8.0.11.tar.gz

[root@c193fcb41eae php-8.0.11]# /usr/local/php8/sbin/php-fpm
[root@c193fcb41eae php-8.0.11]# ss -anlt
State             Recv-Q            Send-Q                       Local Address:Port                       Peer Address:Port           Process            
LISTEN            0                 128                                0.0.0.0:80                              0.0.0.0:*                                 
LISTEN            0                 128                              127.0.0.1:9000                            0.0.0.0:*                                 
LISTEN            0                 80                                       *:3306                                  *:* 

//php启动脚本
[root@c193fcb41eae /]# vi /start.sh
#!/bin/bash
/usr/local/php8/sbin/php-fpm
[root@c193fcb41eae /]# chmod +x /start.sh 


[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND                  CREATED          STATUS          PORTS                                   NAMES
22ce0738d9d7   centos:latest                       "/bin/bash"              46 minutes ago   Up 46 minutes                                           php8
466e7f22d1f3   centos:latest                       "/bin/bash"              2 hours ago      Up 51 minutes                                           mysql01
c193fcb41eae   1314444/source_nginx:nginx-1.21.4   "/usr/local/nginx/sb…"   11 hours ago     Up 2 hours      0.0.0.0:8080->80/tcp, :::8080->80/tcp   nginx05

在这里插入图片描述

制作镜像


[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                     COMMAND                  CREATED          STATUS             PORTS                                   NAMES
b8aff1ca0d45   centos:latest            "./start.sh"             4 seconds ago    Up 3 seconds                                               php8
cb81cdc671e4   centos:latest            "./start.sh"             8 minutes ago    Up 8 minutes                                               mysql01
c193fcb41eae   nginx:latest                       "/usr/local/nginx/sb…"   11 minutes ago   Up 11 minutes      0.0.0.0:8080->80/tcp, :::8080->80/tcp       nginx05

//制作nginx镜像
[root@localhost ~]# docker commit -a ' hhr 123@qq.com' -c 'CMD ["/usr/local/nginx/sbin/nginx"]' nginx05 1314444/lnmp:nginx-v0.1
sha256:ae3a6692a4c0c3a615bdf08ad2941a8526c0acda2b6b6b21dfb625407280ac25

//制作mysql镜像
[root@localhost ~]# docker commit -a ' hhr 123@qq.com' -c 'CMD ["./start.sh"]' mysql01 1314444/lnmp:mysql-v0.1
sha256:ff7d2b91b948baf5ecde42ad6783d80b00fb4c18bc3edc3e9d907f2a7b0e8b96

//制作php镜像
[root@localhost ~]# docker commit -a ' hhr 123@qq.com' -c 'CMD ["./start.sh"]' php8 1314444/lnmp:php8-v0.1
sha256:359cf3ac83b0faea8d17fa4ba7eb3ed149b4ab68b8f625ed20e049d73a2c78ee

[root@localhost ~]# docker images
REPOSITORY             TAG               IMAGE ID       CREATED         SIZE
1314444/lnmp           php8-v0.1         359cf3ac83b0   7 seconds ago   1.56GB
1314444/lnmp           mysql-v0.1        ff7d2b91b948   4 minutes ago   3.81GB
1314444/lnmp           nginx-v0.1        ae3a6692a4c0   7 minutes ago   551MB
centos                 latest            5d0da3dc9764   2 months ago    231MB

用新镜像创建lnmp容器


//启动nginx容器
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

[root@localhost ~]# docker run -d --name nginx -p 80:80 1314444/lnmp:nginx-v0.1
fad400d5145fea77e336200b915fd2321a9ee3c14d0bf8ecb9fe112f8e2b9106
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND         CREATED          STATUS         PORTS                               NAMES
a5346a4eb92b   ae3a6692a4c0   "./start.sh"    10 seconds ago   Up 9 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   nginx

[root@localhost ~]# docker exec -it nginx /bin/bash
[root@a5346a4eb92b /]# ss -anlt
State             Recv-Q            Send-Q                       Local Address:Port                       Peer Address:Port           Process            
LISTEN            0                 128                                0.0.0.0:80                              0.0.0.0:* 
 

//启动mysql容器
[root@localhost ~]# docker run -d --name mysql --network container:fad400d5145f 1314444/lnmp:mysql-v0.1
cb81cdc671e4c266ea9d1537367ab509e1c50a9c29d6741fed632ee6c3ad1ddb
   
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND        CREATED          STATUS          PORTS                               NAMES
861eabb3a5b7   ff7d2b91b948   "./start.sh"   35 seconds ago   Up 34 seconds                                       mysql
a5346a4eb92b   ae3a6692a4c0   "./start.sh"   7 minutes ago    Up 7 minutes    0.0.0.0:80->80/tcp, :::80->80/tcp   nginx

[root@localhost ~]# docker exec -it mysql /bin/bash
[root@a5346a4eb92b /]# 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:*              
LISTEN  0       80                     *:3306                *:*        



//启动php容器
[root@localhost ~]# docker run -d --name php --network container:fad400d5145f 1314444/lnmp:php-v0.1
b8aff1ca0d45033ed1f20071d98678573edec8c6c9c521fc7ddf024b01c0d0f9

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND                  CREATED          STATUS             PORTS                                   NAMES
b8aff1ca0d45   1314444/lnmp:php-v0.1              "./start.sh"             4 seconds ago    Up 3 seconds                                               php
cb81cdc671e4   1314444/lnmp:mysql-v0.1           "./start.sh"             8 minutes ago    Up 8 minutes                                               mysql
fad400d5145f   0229f7e8313f                        "./start.sh"             11 minutes ago   Up 11 minutes      0.0.0.0:80->80/tcp, :::80->80/tcp       nginx

[root@localhost ~]# docker exec -it php /bin/bash
[root@fad400d5145f /]# ss -anlt
State              Recv-Q             Send-Q                         Local Address:Port                         Peer Address:Port             Process             
LISTEN             0                  128                                  0.0.0.0:80                                0.0.0.0:*                                    
LISTEN             0                  128                                127.0.0.1:9000                              0.0.0.0:*                                    
LISTEN             0                  80                                         *:3306                                    *:*  

测试

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

到此这篇关于Docker下部署lnmp详细步骤的文章就介绍到这了,更多相关Docker部署lnmp内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: Docker下部署lnmp详细步骤

本文链接: https://lsjlt.com/news/159221.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • Docker下部署lnmp详细步骤
    目录拉取一个centos镜像基于centos生成nginx容器基于centos生成mysql容器基于centos生成php容器制作镜像用新镜像创建lnmp容器测试拉取一个centos...
    99+
    2024-04-02
  • Docker部署MicrosoftSqlServer详细步骤
    目录1 背景2 创建容器3 修改SA密码4 链接mssql5 容器外链接mssql总结1 背景 自 SQL Server 2019 CU3 起,支持 Ubuntu 18.04。 自 ...
    99+
    2024-04-02
  • Docker部署portainer的详细步骤
    portainer Portainer是Docker的图形化管理工具,由GO语言编写的,提供状态显示、应用模板快速部署、对于Docker(容器、镜像、网络、数据卷)的基本操作、日志显...
    99+
    2024-04-02
  • docker部署lnmp-wordpress的实现步骤
    目录一、实验环境二、安装docker源三、安装docker四、部署Nginx和PHP1、上传/解压软件包和配置文件2、创建dockerfile文件3、构建镜像4、创建容器并运行5、开...
    99+
    2024-04-02
  • Docker容器部署consul的详细步骤
    目录Consul简介Consul 使用场景-consul部署- 容器服务自动加入consul集群安装Gliderlabs/Registrator Gliderlabs/Re...
    99+
    2024-04-02
  • Docker 部署 Gitlab 服务器(详细步骤)
    目录         Gitlab镜像 1、拉取Gitlab镜像 2、启动Gitlab容器  3、修改配置 4、浏览器访问  5、修改root密码 6、gitlab操作 Gitlab镜像 1、拉取Gitlab镜像 docker pul...
    99+
    2023-09-06
    docker
  • Docker下如何部署lnmp
    小编给大家分享一下Docker下如何部署lnmp,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!拉取一个centos镜像//下载centos镜像[root@loca...
    99+
    2023-06-21
  • 基于docker 部署canvas-lms的详细步骤
    准备: 一台8G内存的服务器。安装好docker, pull一个ubuntu镜像下来, 可以是最新版也可以是官方支持的14/ 16 更新时间: 2018-04-04 Step 1: ...
    99+
    2024-04-02
  • LNMP环境下zabbix6.0部署(超详细)
    zabbix6.0-nginx代理 1、MySQL安装 1.1 详见MySQL安装 1.2 创建zabbix初始数据库 2、nginx安装 2.1 下载nginx安装包 2.2 安装相关依赖 2.3 nginx包解压并进入解压目录 2.4 ...
    99+
    2023-09-04
    nginx 服务器 mysql php
  • centos搭建部署docker环境的详细步骤
    目录1、Docker的存在解决的问题1.1 统一标准1.2 资源隔离2、Docker的建构3、安装Docker1、卸载以前安装的docker2、配置yun源3、安装docker4、启动docker并设置为开机自启5、查看一下当前的docke...
    99+
    2024-04-02
  • Linux系统docker部署.net core3.1的详细步骤
    此篇文章演示基本的基于docker部署.netcore服务,linux系统腾讯云ubuntu,.net core版本3.1。 1.安装docker apt install docke...
    99+
    2024-04-02
  • docker部署mysql并挂载外部文件详细步骤
    去搜索mysql的镜像 docker search mysql 选择自己需要的版本对应的镜像,拉取镜像 docker pull mysql 不带版本号默认拉取最新版本对的镜像 创建外部挂载的文件...
    99+
    2023-09-20
    mysql docker
  • 部署MySQL的详细步骤
    本篇内容主要讲解“部署MySQL的详细步骤”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“部署MySQL的详细步骤”吧! 1.新建配...
    99+
    2024-04-02
  • 在Docker快速部署Node.js应用的详细步骤
    一、前言 可能还有一些同学不了解docker这个项目,docker是由go语言编写的,一个快速部署的轻量级虚拟技术项目,他允许开发人员将自己的程序和运行环境一起打包,制作成一个docker的image(镜像...
    99+
    2022-06-04
    步骤 快速 详细
  • Docker容器下部署Git的步骤
    这篇文章主要讲解了“Docker容器下部署Git的步骤”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Docker容器下部署Git的步骤”吧!老办法 我实在没...
    99+
    2024-04-02
  • IDEA 集成 docker 实现远程部署的详细步骤
    1. docker 服务器开启远程访问 登录 docker 所在的远程服务器,使用命令 vim /usr/lib/systemd/system/docker.service 修改配置...
    99+
    2024-04-02
  • kafka安装部署超详细步骤
    目录概述Step 1: 下载代码Step 2: 启动服务Step 3:创建一个主题Step 4: 发送消息Step 5: 消费消息Step 6: 设置多个broker集群(单机伪集群...
    99+
    2024-04-02
  • Linux+Docker+SpringBoot+IDEA一键自动化部署的详细步骤
    Linux+Docker+SpringBoot+IDEA一键自动化部署的步骤 记录从打包到服务器配置上线全流程 安装docker 详细步骤请戳这里 用yum源安装用yum源安装 查看是否已安装docker列表 ...
    99+
    2022-06-03
    Linux Docker SpringBoot IDEA一键自动化部署 IDEA一键自动化部署
  • Docker部署java项目的详细步骤(利用Dockerfile方式)
    目录前言1. 首先找一个你熟悉的目录下创建一个目录upload(这个目录可以随便),并把java的linux和jar包上传进去2. 创建一个名为 Dockerfile文件3. 以上命...
    99+
    2022-11-13
    docker如何部署java项目 docker下部署java的web应用 docker搭建java环境
  • Linux下安装Docker的详细步骤
    本篇内容主要讲解“Linux下安装Docker的详细步骤”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux下安装Docker的详细步骤”吧!先说明下我用的系统是Linux Cen...
    99+
    2023-06-05
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作