- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章通过docker容器搭建lamp架构的流程由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
1
2
3
4
5
6
7
8
9
10
11
|
[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
[root@localhost ~]
#
|
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
|
[root@localhost ~]
# docker run --name nginx -it centos
[root@522006030d19 /]
# useradd -r -M -s /sbin/nologin nginx
[root@522006030d19 /]
# yum -y install pcre-devel pcre gcc gcc-c++ openssl-devel zlib zlib-devel make vim wget openssl openssl-devel gd-devel
[root@522006030d19 /]
# mkdir -p /var/log/nginx
[root@522006030d19 /]
# chown -R nginx.nginx /var/log/nginx
[root@522006030d19 /]
# cd /usr/src/
[root@522006030d19 src]
# wget https://nginx.org/download/nginx-1.20.1.tar.gz
[root@522006030d19 src]
# tar xf nginx-1.20.1.tar.gz
[root@522006030d19 src]
# cd nginx-1.20.1
[root@522006030d19 nginx-1.20.1]
# ./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@522006030d19 nginx-1.20.1]
# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install
[root@522006030d19 nginx-1.20.1]
# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh[root@522006030d19 nginx-1.20.1]# source /etc/profile.d/nginx.sh
[root@522006030d19 nginx-1.20.1]
# nginx
[root@522006030d19 nginx-1.20.1]
# 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@522006030d19 nginx-1.20.1]
#
[root@522006030d19 nginx-1.20.1]
# echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf
[root@522006030d19 nginx-1.20.1]
# tail -1 /usr/local/nginx/conf/nginx.conf
daemon off;
[root@522006030d19 nginx-1.20.1]
#
|
1
2
3
4
5
6
7
8
|
//
打开另外一个终端
[root@localhost ~]
# docker commit -c 'CMD ["/usr/local/nginx/sbin/nginx"]'-p nginx pengyudong/nginx:v1
sha256:2153a12060f6cca88646f285a1ae2af2a94c0d489ad8393f931d29c8fdd8af6e
[root@localhost ~]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pengyudong
/nginx
v1 2153a12060f6 27 seconds ago 576MB
centos latest 5d0da3dc9764 2 months ago 231MB
[root@localhost ~]
#
|
1
2
3
4
5
6
7
8
9
10
11
|
[root@localhost ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost ~]
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
522006030d19 centos
"/bin/bash"
14 minutes ago Exited (0) 38 seconds ago nginx
[root@localhost ~]
# docker rm 522006030d19
522006030d19
[root@localhost ~]
# docker run pengyudong/nginx:v1
[root@localhost ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9c129a20e7c7 pengyudong
/nginx
:v1
"/usr/local/nginx/sb…"
About a minute ago Up 2 seconds blissful_perlman
|
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
|
[root@localhost ~]
# docker inspect 9c129a20e7c7
......省略N行
"Gateway"
:
"172.17.0.1"
,
"GlobalIPv6Address"
:
""
,
"GlobalIPv6PrefixLen"
: 0,
"IPAddress"
:
"172.17.0.2"
,
.....省略N行
[root@localhost ~]
# curl 172.17.0.2
<!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/"
rel=
"external nofollow"
>nginx.org<
/a
>.<br/>
Commercial support is available at
<a href=
"http://nginx.com/"
rel=
"external nofollow"
>nginx.com<
/a
>.<
/p
>
<p><em>Thank you
for
using nginx.<
/em
><
/p
>
<
/body
>
<
/html
>
[root@localhost ~]
#
|
1
2
3
4
5
|
[root@localhost ~]
# docker run --name mysql -it centos
[root@16256ee64b9e /]
# cd /usr/src/
[root@16256ee64b9e src]
# ls
debug kernels
[root@16256ee64b9e src]
#
|
1
2
3
4
5
|
//
开启另外一个终端
[root@localhost src]
# ls
debug kernels mysql-5.7.34-linux-glibc2.12-x86_64.
tar
.gz
[root@localhost ~]
# cd /usr/src/
[root@localhost src]
# docker cp mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz mysql:/usr/src/
|
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
|
[root@16256ee64b9e src]
# ls
debug kernels mysql-5.7.34-linux-glibc2.12-x86_64.
tar
.gz
[root@16256ee64b9e src]
#
[root@16256ee64b9e src]
# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel ncurses-compat-libs libaio numactl
[root@16256ee64b9e src]
# useradd -r -M -s /sbin/nologin mysql
[root@16256ee64b9e src]
# tar xf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
[root@16256ee64b9e src]
# mv mysql-5.7.34-linux-glibc2.12-x86_64 /usr/local/mysql
[root@16256ee64b9e src]
# cd /usr/local/
[root@16256ee64b9e
local
]
# ls
bin etc games include lib lib64 libexec mysql sbin share src
[root@16256ee64b9e
local
]
# chown -R mysql.mysql /usr/local/mysql
[root@16256ee64b9e
local
]
# mkdir /opt/data
[root@16256ee64b9e
local
]
# chown -R mysql.mysql /opt/data
[root@16256ee64b9e
local
]
# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/opt/data
2021-12-06T02:53:34.095554Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation
for
more
details).
2021-12-06T02:53:35.482793Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-12-06T02:53:35.506011Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-12-06T02:53:35.562063Z 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: b4aa24d8-563f-11ec-80a8-0242ac110003.
2021-12-06T02:53:35.562798Z 0 [Warning] Gtid table is not ready to be used. Table
'mysql.gtid_executed'
cannot be opened.
2021-12-06T02:53:35.979249Z 0 [Warning] CA certificate ca.pem is self signed.
2021-12-06T02:53:36.217615Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@16256ee64b9e
local
]
#
[root@16256ee64b9e
local
]
# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@16256ee64b9e
local
]
# . /etc/profile.d/mysql.sh
[root@16256ee64b9e
local
]
# echo $PATH
/usr/local/mysql/bin
:
/usr/local/sbin
:
/usr/local/bin
:
/usr/sbin
:
/usr/bin
:
/sbin
:
/bin
[root@16256ee64b9e
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@16256ee64b9e
local
]
# cat /etc/m
machine-
id
modprobe.d/ motd my.cnf
makedumpfile.conf.sample modules-load.d/ mtab my.cnf.d/
[root@16256ee64b9e
local
]
# cat /etc/my.cnf
[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
[root@16256ee64b9e
local
]
#
[root@16256ee64b9e
local
]
# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /usr/local/mysql/support-files/mysql.server
[root@16256ee64b9e
local
]
# sed -ri 's#^(datadir=).*#\1/opt/data#g' /usr/local/mysql/support-files/mysql.server
[root@16256ee64b9e
local
]
# sed -n '46,1p' /usr/local/mysql/support-files/mysql.server
basedir=
/usr/local/mysql
[root@16256ee64b9e
local
]
# sed -n '47,1p' /usr/local/mysql/support-files/mysql.server
datadir=
/opt/data
[root@16256ee64b9e
local
]
# sed -n '46,47p' /usr/local/mysql/support-files/mysql.server
basedir=
/usr/local/mysql
datadir=
/opt/data
[root@16256ee64b9e
local
]
#
[root@16256ee64b9e ~]
# /usr/local/mysql/support-files/mysql.server start
Starting MySQL.Logging to
'/opt/data/16256ee64b9e.err'
.
SUCCESS!
[root@16256ee64b9e ~]
# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 80 *:3306 *:*
[root@16256ee64b9e ~]
# 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(
'123'
);
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
exit
Bye
[root@16256ee64b9e ~]
#
[root@16256ee64b9e ~]
# mkdir /scripts
[root@16256ee64b9e ~]
# vi /scripts/start.sh
[root@16256ee64b9e ~]
# sed -n '1,3p' /scripts/start.sh
#!/bin/bash
/usr/local/mysql/support-files/mysql
.server start
/bin/bash
[root@16256ee64b9e ~]
# chmod +x /scripts/start.sh
[root@localhost ~]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pengyudong
/nginx
v1 2153a12060f6 28 minutes ago 576MB
centos latest 5d0da3dc9764 2 months ago 231MB
[root@localhost ~]
# docker commit -c 'CMD ["/scripts/start.sh"]' -p mysql pengyudong/mysql:v1
sha256:9c8b9aa2d9177e737138f7a42976210fd6e7b039cb543c306281be72c351806e
[root@localhost ~]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pengyudong
/mysql
v1 9c8b9aa2d917 4 seconds ago 3.81GB
pengyudong
/nginx
v1 2153a12060f6 30 minutes ago 576MB
centos latest 5d0da3dc9764 2 months ago 231MB
|
[root@localhost ~]# docker run --name mysql-1 -dit --net=container:97c5a3076d39 pengyudong/mysql:v1 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ade839dc292e pengyudong/mysql:v1 “/scripts/start.sh” 12 minutes ago Up 12 minutes mysql-1 29007b1a67a8 pengyudong/nginx:v1 “/usr/local/nginx/sb…” 2 hours ago Up About an hour [root@localhost ~]# docker exec -it mysql-1 /bin/bash [root@29007b1a67a8 /]# 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
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
|
[root@localhost ~]
# cd /usr/src/
[root@localhost src]
# ls
debug kernels mysql-5.7.34-linux-glibc2.12-x86_64.
tar
.gz php-8.0.10.
tar
.gz
[root@localhost src]
# docker cp php-8.0.10.tar.gz php8:/usr/src/
[root@a116c2a489fe src]
# ls
debug kernels php-8.0.10.
tar
.gz
[root@a116c2a489fe src]
# yum -y install epel-release
[root@a116c2a489fe src]
# yum -y install sqlite-devel libzip-devel libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel pcre-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel oniguruma gcc gcc-c++ make libcurl-devel
[root@a116c2a489fe src]
# yum -y install http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
[root@a116c2a489fe src]
# tar xf php-8.0.10.tar.gz
[root@a116c2a489fe src]
# cd php-8.0.10
[root@a116c2a489fe php-8.0.10]
# ./configure --prefix=/usr/local/php8 \
> --with-config-
file
-path=
/etc
\
> --
enable
-fpm \
> --disable-debug \
> --disable-rpath \
> --
enable
-shared \
> --
enable
-soap \
nable-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 \
--en> --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
[root@a116c2a489fe php-8.0.10]
# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install
[root@a116c2a489fe php-8.0.10]
# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php.sh
[root@a116c2a489fe php-8.0.10]
# source /etc/profile.d/php.sh
[root@a116c2a489fe php-8.0.10]
# cp -f /usr/src/php-8.0.10/php.ini-production /etc/php.i
cp
: overwrite
'/etc/php.i'
?
yes
[root@a116c2a489fe php-8.0.10]
# cp -f /usr/src/php-8.0.10/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@a116c2a489fe php-8.0.10]
# chmod +x /etc/init.d/php-fpm
[root@a116c2a489fe php-8.0.10]
# cp -f /usr/local/php8/etc/php-fpm.conf.default /usr/local//php8/etc/php-fpm.conf
[root@a116c2a489fe php-8.0.10]
# cp -f /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf
[root@a116c2a489fe php-8.0.10]
# mkdir /scripts
[root@a116c2a489fe php-8.0.10]
# vi /scripts/start.sh
[root@a116c2a489fe php-8.0.10]
# cat /scripts/start.sh
#!/bin/bash
/etc/init
.d
/php-fpm
start
/bin/bash
[root@a116c2a489fe php-8.0.10]
# chmod +x /scripts/start.sh
[root@a116c2a489fe php-8.0.10]
# /etc/init.d/php-fpm start
Starting php-fpm
done
[root@a116c2a489fe php-8.0.10]
# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
[root@a116c2a489fe php-8.0.10]
#
|
[root@0e6298ebe47d php-8.0.10]# [root@0e6298ebe47d php-8.0.10]# mkdir -p /var/www/html [root@0e6298ebe47d php-8.0.10]# vi /var/www/html/index.php [root@0e6298ebe47d php-8.0.10]# cat /var/www/html/index.php 。
<?php phpinfo(); ?> 。
[root@0e6298ebe47d php-8.0.10]# 。
1
2
3
4
5
6
7
8
9
|
[root@localhost src]
# docker commit -c 'CMD ["/bin/bash","/scripts/start.sh"]' -p php8 pengyudong/php8:v1
sha256:8ee4d3fb7bd27b0242cf096464932ff98fbc42d641d1f6b9cac7ddccb429f450
[root@localhost src]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pengyudong
/php8
v1 8ee4d3fb7bd2 22 seconds ago 1.52GB
pengyudong
/mysql
v1 9c8b9aa2d917 30 minutes ago 3.81GB
pengyudong
/nginx
v1 2153a12060f6 About an hour ago 576MB
centos latest 5d0da3dc9764 2 months ago 231MB
[root@localhost src]
#
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
//
配置nginx
[root@localhost ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a116c2a489fe centos
"/bin/bash"
28 minutes ago Up 28 minutes php8
16256ee64b9e centos
"/bin/bash"
55 minutes ago Up 29 minutes mysql
9c129a20e7c7 pengyudong
/nginx
:v1
"/usr/local/nginx/sb…"
59 minutes ago Up 57 minutes blissful_perlman
[root@localhost ~]
# docker exec -it 9c129a20e7c7 /bin/bash
[root@9c129a20e7c7 ~]
# vi /usr/local/nginx/conf/nginx.conf
...
location / {
root html;
index index.php index.html index.htm;
//
加入index.php
}
...
location ~ \.php$ {
root
/var/www/html
;
//
修改
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $Document_root$fastcgi_script_name;
//
修改
include fastcgi_params;
}
...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@localhost ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a116c2a489fe centos
"/bin/bash"
35 minutes ago Up 35 minutes php8
16256ee64b9e centos
"/bin/bash"
About an hour ago Up 36 minutes mysql
9c129a20e7c7 pengyudong
/nginx
:v1
"/usr/local/nginx/sb…"
About an hour ago Up 46 seconds blissful_perlman
[root@localhost ~]
# docker commit -c 'CMD ["/usr/local/nginx/sbin/nginx"]'-p 9c129a20e7c7 pengyudong/nginx:v2
sha256:8ca4733bb94edf9dac98982610e626b663052000d2c165127e257eeebec34027
[root@localhost ~]
#
sha256:dd9ec3401a3df247bc19cb792a076cfa915e67cb88fdbdfbf2284bbda6ac9a78
[root@localhost ~]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pengyudong
/nginx
v2 dd9ec3401a3d 7 seconds ago 576MB
pengyudong
/php8
v1 8ee4d3fb7bd2 8 minutes ago 1.52GB
pengyudong
/mysql
v1 9c8b9aa2d917 38 minutes ago 3.81GB
pengyudong
/nginx
v1 2153a12060f6 About an hour ago 576MB
centos latest 5d0da3dc9764 2 months ago 231MB
[root@localhost ~]
#
|
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
|
//
配置php
[root@localhost ~]
# docker exec -it php8 /bin/bash
[root@a116c2a489fe /]
# mkdir -p /var/www/html
[root@a116c2a489fe /]
# vi /var/www/html/index.php
[root@a116c2a489fe /]
# cat /var/www/html/index.php
<?php
phpinfo();
?>
[root@a116c2a489fe /]
#
[root@localhost ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a116c2a489fe centos
"/bin/bash"
37 minutes ago Up 37 minutes php8
16256ee64b9e centos
"/bin/bash"
About an hour ago Up 38 minutes mysql
9c129a20e7c7 pengyudong
/nginx
:v1
"/usr/local/nginx/sb…"
About an hour ago Up 3 minutes blissful_perlman
[root@localhost ~]
# docker commit -c 'CMD ["/bin/bash","/scripts/start.sh"]' -p php8 pengyudong/php8:v2
sha256:6e582cd9d5e8ce4b91addb12e6a53a6e3f5cf762aabe2ce24e5f6396ec3f15ed
[root@localhost ~]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pengyudong
/php8
v2 6e582cd9d5e8 8 seconds ago 1.52GB
pengyudong
/nginx
v2 dd9ec3401a3d 2 minutes ago 576MB
pengyudong
/php8
v1 8ee4d3fb7bd2 10 minutes ago 1.52GB
pengyudong
/mysql
v1 9c8b9aa2d917 40 minutes ago 3.81GB
pengyudong
/nginx
v1 2153a12060f6 About an hour ago 576MB
centos latest 5d0da3dc9764 2 months ago 231MB
[root@localhost ~]
#
|
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
|
//
使用container模式使容器间通信
[root@localhost ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a116c2a489fe centos
"/bin/bash"
38 minutes ago Up 38 minutes php8
16256ee64b9e centos
"/bin/bash"
About an hour ago Up 40 minutes mysql
9c129a20e7c7 pengyudong
/nginx
:v1
"/usr/local/nginx/sb…"
About an hour ago Up 4 minutes blissful_perlman
[root@localhost ~]
# docker rm -f a116c2a489fe 16256ee64b9e 9c129a20e7c7
a116c2a489fe
16256ee64b9e
9c129a20e7c7
[root@localhost ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost ~]
#
[root@localhost ~]
# docker run --name nginx -dit -p 80:80 pengyudong/nginx:v2
f64441e51181b9dc41806a9b1363a22ce28fd83f4cbd7f85df6eed88774a4197
[root@localhost ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f64441e51181 pengyudong
/nginx
:v2
"/usr/local/nginx/sb…"
7 seconds ago Up 7 seconds 0.0.0.0:80->80
/tcp
, :::80->80
/tcp
nginx
[root@localhost ~]
#
[root@localhost ~]
# docker run --name mysql -dit --net=container:f64441e51181 pengyudong/mysql:v1
96530de34b37a5fc6af1564df64f423321b04641f6aea5a3dd5be199f02a8510
[root@localhost ~]
# docker run --name php8 -dit --net=container:f64441e51181 pengyudong/php8:v2
27834149fc66f007ba1cca5d298351d39f7d819af3f1ec6fcf8e12bbdc39fb4d
[root@localhost ~]
#
[root@localhost ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
27834149fc66 pengyudong
/php8
:v2
"/bin/bash /scripts/…"
29 seconds ago Up 28 seconds php8
96530de34b37 pengyudong
/mysql
:v1
"/scripts/start.sh"
About a minute ago Up About a minute mysql
f64441e51181 pengyudong
/nginx
:v2
"/usr/local/nginx/sb…"
2 minutes ago Up 2 minutes 0.0.0.0:80->80
/tcp
, :::80->80
/tcp
nginx
[root@localhost ~]
# docker exec -it nginx /bin/bash
[root@f64441e51181 /]
# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
[root@f64441e51181 /]
#
|
到此这篇关于docker容器搭建lamp架构的文章就介绍到这了,更多相关docker搭建lamp内容请搜索我以前的文章或继续浏览下面的相关文章希望大家以后多多支持我! 。
原文链接:https://blog.csdn.net/qq_49530779/article/details/121710002 。
最后此篇关于通过docker容器搭建lamp架构的流程的文章就讲到这里了,如果你想了解更多关于通过docker容器搭建lamp架构的流程的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
为了构建 CentOS 6.5 OSM 切片服务器,我正在寻找一些文档和/或教程。 我试过this one正如我在我的 previous post 中所说的那样但它适用于 Ubuntu 14.04,而
我正在寻找可用于集成任何源代码控制管理系统的通用 git 桥(如 git-svn、git-p4、git-tfs)模板。 如果没有这样的模板,至少有一些关于如何在 git 端集成基本操作的说明(对于其他
1、前言 redis在我们企业级开发中是很常见的,但是单个redis不能保证我们的稳定使用,所以我们要建立一个集群。 redis有两种高可用的方案: High availabilit
简介 前提条件: 确保本机已经安装 VS Code。 确保本机已安装 SSH client, 并且确保远程主机已安装 SSH server。 VSCode 已经安装了插件 C/
为什么要用ELK ELK实际上是三个工具,Elastricsearch + Logstash + Kibana,通过ELK,用来收集日志还有进行日志分析,最后通过可视化UI进行展示。一开始业务量比
在日常办公当中,经常会需要一个共享文件夹来存放一些大家共享的资料,为了保证文件数据的安全,最佳的方式是公司内部服务器搭建FTP服务器,然后分配多个用户给相应的人员。今天给大家分享FileZilla搭
最近由于业务需要,开始进行 Flutter 的研究,由于 Flutter 的环境搭建在官网上有些细节不是很清楚,笔者重新整理输出 1. 配置镜像 由于在国内访问 Flutter
目录 1. 安装go软件包 2. 配置系统变量 3. 安装git 4. 设置go代理 5. 下载gin框架 6. 创建项目 7.
Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任
上篇文章给大家介绍了使用docker compose安装FastDfs文件服务器的实例详解 今天给大家介绍如何使用 docker compose 搭建 fastDFS文件服务器,内容详情如下所示:
目录 1.创建Maven 2.Maven目录和porm.xml配置 3.配置Tomcat服务器 1.创建Maven
laravel 官方提供 homestead 和 valet 作为本地开发环境,homestead 是一个官方预封装的 vagrant box,也就是一个虚拟机,但是跟 docker 比,它占用体积
这个tutorial显示了 Razor Pages 在 Asp.Net Core 2 中的实现。但是,当我运行 CLI 命令时: dotnet aspnet-codegenerator razorp
我创建了一个单独的类库项目来存储数据库上下文和模型类。在同一解决方案中,我创建了一个 ASP.NET MVC 项目并引用了类库项目,并在项目的 Web.config 文件中包含了数据库上下文的连接字符
关于代码托管,公司是基于Gitlab自建的,它功能全而强大,但是也比较重,我个人偏向于开源、小巧、轻便、实用,所以就排除了Github,在Gogs和Gitea中选者。Gogs在Github有38
目录 1、高可用简介 1.1 高可用整体架构 1.2 基于 QJM 的共享存储系统的数据同步机制分析 1.3 NameNode 主
Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。 在高并发连接的情况
对于我们的 ASP.NET Core 项目,我们使用包管理器控制台中的 Scaffold-DbContext 搭建现有数据库。 每次我们做脚手架时,上下文类与所有实体一起生成,它包含调用 option
我正在使用 .net 核心 2.0。我已经安装了以下 nuget 包:1: Microsoft.AspNetCore.All2: Microsoft.EntityFrameworkCore.Tools
我正在使用 NetBeans 及其 RAD 开发功能开发 JEE6 JSF 应用程序。我想使用脚手架来节省更新 Controller 和模型 View 的时间。 OneToMany 关联在 View
我是一名优秀的程序员,十分优秀!