- 容器 webphp1 是背景執行 /usr/sbin/httpd,提供 php 互動式網頁,要如何修改系統呢?
[root@dyw219 ~]# docker ps
CONTAINER ID COMMAND PORTS NAMES
e1e597e63f3c "/usr/sbin/httpd -D F" 0.0.0.0:32777->80/tcp, 0.0.0.0:32776->443/tcp webphp1
282553feccf2 "container-entrypoint" 3306/tcp mdb
- docker exec 可以進入容器 webphp1 並執行 bash,取得與系統互動的界面。查看網頁根目錄 /var/www/html 下有 index.php 及 error.php,是之前複製進容器的測試網頁,所以可以確定目前的容器的確是 webphp1。
[root@dyw219 ~]# docker exec -it webphp1 bash
[root@e1e597e63f3c /]# ll /var/www/html/
total 8
-rw-r--r--. 1 root root 245 Aug 17 23:40 error.php
-rw-r--r--. 1 root root 244 Aug 17 23:38 index.php
- 進入 webphp1 容器後,就可以跟操作所有 Linux 系統一樣,uname -a 查看核心版本。
[root@e1e597e63f3c /]# uname -a
Linux e1e597e63f3c 4.4.5-1.el6.elrepo.x86_64 #1 SMP Thu Mar 10 13:51:50 EST
2016 x86_64 x86_64 x86_64 GNU/Linux
- 查看與 php 相關的安裝套件。
[root@e1e597e63f3c /]# rpm -qa | grep php
php-mcrypt-5.6.21-1.el7.remi.x86_64
php-opcache-5.6.21-1.el7.remi.x86_64
php-pecl-jsonc-1.3.9-1.el7.remi.5.6.x86_64
php-pecl-zip-1.13.2-1.el7.remi.5.6.x86_64
php-xml-5.6.21-1.el7.remi.x86_64
php-pecl-jsonc-devel-1.3.9-1.el7.remi.5.6.x86_64
php-mbstring-5.6.21-1.el7.remi.x86_64
php-pear-1.10.1-4.el7.remi.noarch
php-twig-1.24.0-1.el7.remi.5.6.x86_64
php-5.6.21-1.el7.remi.x86_64
php-pecl-xdebug-2.4.0-1.el7.remi.5.6.x86_64
php-gd-5.6.21-1.el7.remi.x86_64
php-common-5.6.21-1.el7.remi.x86_64
php-cli-5.6.21-1.el7.remi.x86_64
php-devel-5.6.21-1.el7.remi.x86_64
php-pdo-5.6.21-1.el7.remi.x86_64
php-process-5.6.21-1.el7.remi.x86_64
php-pecl-xhprof-0.9.4-4.el7.remi.5.6.x86_64
php-mysqlnd-5.6.21-1.el7.remi.x86_64
php-fpm-5.6.21-1.el7.remi.x86_64
- yum 查看套件庫,確實是 CentOS 7。
[root@e1e597e63f3c /]# yum repolist
Loaded plugins: fastestmirror, ovl
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors
* base: ftp.tc.edu.tw
* epel: mirror.symnds.com
* extras: ftp.tc.edu.tw
* remi-safe: ftp.riken.jp
* updates: ftp.tc.edu.tw
repo id repo name status
!base/7/x86_64 CentOS-7 - Base 9007
!epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 10055
!extras/7/x86_64 CentOS-7 - Extras 303
!remi-safe Safe Remi's RPM repository for Enterprise Linux 7 - x86 812
!updates/7/x86_64 CentOS-7 - Updates 1676
repolist: 21853
- 退出容器 webphp1。
[root@e1e597e63f3c /]# exit
exit