- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章Docker下部署lnmp详细步骤由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
1
2
3
4
5
6
7
8
9
10
11
12
13
|
//
下载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
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
//
使用镜像启动容器并进入容器
[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
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
//
做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的时候,报以下错误 。
1
2
3
4
|
error
while
loading shared libraries: libnuma.so.1: cannot
open
shared object
file
: No such
file
or directory
//
解决方法
yum -y
install
numactl libaio
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
//
运行一个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
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
[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
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
//
启动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内容请搜索我以前的文章或继续浏览下面的相关文章希望大家以后多多支持我! 。
原文链接:https://blog.csdn.net/qq_48289488/article/details/121705501 。
最后此篇关于Docker下部署lnmp详细步骤的文章就讲到这里了,如果你想了解更多关于Docker下部署lnmp详细步骤的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我正在使用以下dockerfile: FROM ubuntu:14.04 MAINTAINER xxx xxx # SSH RUN apt-get update && apt-get install
我运行了docker-compose build celery,(经过数小时的尝试,我的连接不良)成功了。 app Dockerfile的前80%是相同的,但不会重复使用缓存。从我可以浏览的内容来看,
我可以使用以下命令成功创建 Docker 注册表 v2 服务:docker service create 然后我使用 docker Push 将一些图像推送到该服务。 当我通过 curl localh
我正在尝试使用 gitlab 构建 CI,我从 docker 的 docker 镜像开始,我的前端存储库没有任何问题,但现在使用相同的 gitlab-ci 配置文件,我有此守护程序错误。 这是构建的输
用例: 我们在 Jenkins 中有几个“发布作业”build 和 push 应用程序的 Docker 镜像到 docker registry,更新各种文件中的项目版本,最后将发布标签推送到相应的 G
当我尝试构建我的 docker 文件时,docker 返回以下错误: [+] Building 0.0s (1/2)
docker-in-docker 的作者在此博客中建议不要将此图像用于 CI 目的: jpetazzo/Using Docker-in-Docker for your CI or testing en
我创建了一个 Dockerfile 来在 Docker 中运行 Docker: FROM ubuntu:16.04 RUN apt-get update && \ apt-get in
我尝试为 Docker 镜像定位一个特定标签。我怎样才能在命令行上做到这一点?我想避免下载所有图像,然后删除不需要的图像。 在 Ubuntu 官方版本中,https://registry.hub.do
我正在尝试在docker中运行docker。唯一的目的是实验性的,我绝不尝试实现任何功能,我只想检查docker从另一个docker运行时的性能。 我通过Mac上的boot2docker启动docke
docker-compose.yml version: "3" services: daggr: image: "docker.pvt.com/test/daggr:stable"
我有一个非常具体的开发环境用例。在一些代码中,我启动了一个容器来抓取页面并检索在容器中运行的服务(Gitlab)的 token 。 现在,我希望 Dockerize 运行它的代码。具体来说,类似: o
之前已经问过这个问题,但我不确定当时是否可以使用docker-compose文件完成docker堆栈部署。 由于最新版本支持使用compose将服务部署到堆栈,因此,我无法理解dab文件的值。 我检查
我在一次采访中被问到这个问题,但无法回答。也没有找到任何相关信息。 最佳答案 正如 Docker 文档中所述,Docker 注册表是: [...] a hosted service containin
有没有一种方法可以将具有给定扩展名的所有文件复制到Docker中的主机?就像是 docker cp container_name:path/to/file/in/docker/*.png path/o
我的日志驱动程序设置为journald。使用日志记录驱动程序时,daemon.json文件中的日志级别配置会影响日志吗?使用docker logs 时仅会影响容器日志? 例如,docker和journ
我最近开始使用Docker + Celery。我还共享了full sample codes for this example on github,以下是其中的一些代码段,以帮助解释我的观点。 就上下文
运行docker build .命令后,尝试提交构建的镜像,但收到以下错误 Step 12 : CMD activator run ---> Using cache ---> efc82ff1ca
我们有docker-compose.yml,其中包含Kafka,zookeeper和schema registry的配置 当我们启动docker compose时,出现以下错误 docker-comp
我是Docker的新手。是否可以在Docker Hub外部建立Docker基本镜像存储库?假设将它们存储在您的云中,而不是拥有DH帐户?谢谢。 最佳答案 您可以根据需要托管自己的注册表。可以在Depl
我是一名优秀的程序员,十分优秀!