• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to setup LAMP Stack on Docker with Oracle Linux 9.3

  • 00:34 cat /etc/os-release
  • 00:56 dnf config-manager --add-repo
  • 01:06 dnf install docker-ce docker-ce-cli containerd.io
  • 02:02 systemctl start docker
  • 02:12 systemctl enable docker
  • 02:26 systemctl status docker
  • 02:49 dnf install git
  • 03:09 cd /
  • 03:18 git clone https://github.com/jcavat/docker-lamp.git
  • 03:31 ll
  • 03:47 cd docker-lamp/
  • 03:57 ll
  • 04:06 vim docker-compose.yml
  • 04:29 vim Dockerfile
  • 04:49 cd www/
  • 05:01 vim index.php
  • 05:32 cd ..
  • 05:42 docker compose up -d
  • 07:43 docker ps -a
  • 09:46 docker compose exec db mysql -u root -p
  • 11:15 docker compose down
  • 11:45 docker ps -a
{{postValue.id}}

To Setup LAMP Stack On Docker With Oracle Linux 9.3

Introduction

A Docker LAMP stack is a software package that consists of Linux operating system, Apache web server, MySQL database management system, and PHP server-side scripting language. It is containerized with Docker technology, simplifying deployment and maintenance.

Procedure Steps

Step 1: Check the OS version by using the following command

[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3

Step 2: Add the official Docker repository by using the following command.

[root@linuxhelp ~]# dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo

Step 3: With the repository added, install Docker, which is composed of three packages by using the following command

[root@linuxhelp ~]# dnf install docker-ce docker-ce-cli containerd.io
Docker CE Stable - x86_64                                                                                 251 kB/s |  51 kB     00:00    
Oracle Linux 9 BaseOS Latest (x86_64)                                                                      41 kB/s | 4.2 kB     00:00    
Oracle Linux 9 BaseOS Latest (x86_64)                                                                      22 MB/s |  28 MB     00:01    
Oracle Linux 9 Application Stream Packages (x86_64)                                                        44 kB/s | 4.5 kB     00:00    
Oracle Linux 9 Application Stream Packages (x86_64)                                                        26 MB/s |  37 MB     00:01    
Oracle Linux 9 UEK Release 7 (x86_64)                                                                      35 kB/s | 3.5 kB     00:00    
Oracle Linux 9 UEK Release 7 (x86_64)                                                                      25 MB/s |  36 MB     00:01    
Dependencies resolved.
==========================================================================================================================================
 Package                                   Architecture           Version                          Repository                        Size
==========================================================================================================================================
Installing:
 containerd.io                             x86_64                 1.7.18-3.1.el9                   docker-ce-stable                  44 M
 docker-ce                                 x86_64                 3:27.0.3-1.el9                   docker-ce-stable                  27 M
 docker-ce-cli                             x86_64                 1:27.0.3-1.el9                   docker-ce-stable                 7.8 M
Installing weak dependencies:
 docker-buildx-plugin                      x86_64                 0.15.1-1.el9                     docker-ce-stable                  13 M
 docker-ce-rootless-extras                 x86_64                 27.0.3-1.el9                     docker-ce-stable                 4.0 M
 docker-compose-plugin                     x86_64                 2.28.1-1.el9                     docker-ce-stable                  13 M

Transaction Summary
==========================================================================================================================================
Install  6 Packages

Total download size: 109 M
Installed size: 421 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): docker-buildx-plugin-0.15.1-1.el9.x86_64.rpm                                                       7.3 MB/s |  13 MB     00:01    
(2/6): docker-ce-27.0.3-1.el9.x86_64.rpm                                                                   11 MB/s |  27 MB     00:02    
(3/6): docker-ce-rootless-extras-27.0.3-1.el9.x86_64.rpm                                                   13 MB/s | 4.0 MB     00:00    
(4/6): docker-ce-cli-27.0.3-1.el9.x86_64.rpm                                                              7.5 MB/s | 7.8 MB     00:01    
(5/6): containerd.io-1.7.18-3.1.el9.x86_64.rpm                                                             14 MB/s |  44 MB     00:03    
(6/6): docker-compose-plugin-2.28.1-1.el9.x86_64.rpm                                                       21 MB/s |  13 MB     00:00    
------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                      32 MB/s | 109 MB     00:03     
Docker CE Stable - x86_64                                                                                  28 kB/s | 1.6 kB     00:00    
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                  1/1 
  Installing       : docker-compose-plugin-2.28.1-1.el9.x86_64                                                                        1/6 
  Running scriptlet: docker-compose-plugin-2.28.1-1.el9.x86_64                                                                        1/6 
  Installing       : docker-buildx-plugin-0.15.1-1.el9.x86_64                                                                         2/6 
  Running scriptlet: docker-buildx-plugin-0.15.1-1.el9.x86_64                                                                         2/6 
  Installing       : docker-ce-cli-1:27.0.3-1.el9.x86_64                                                                              3/6 
  Running scriptlet: docker-ce-cli-1:27.0.3-1.el9.x86_64                                                                              3/6 
  Installing       : containerd.io-1.7.18-3.1.el9.x86_64                                                                              4/6 
  Running scriptlet: containerd.io-1.7.18-3.1.el9.x86_64                                                                              4/6 
  Installing       : docker-ce-rootless-extras-27.0.3-1.el9.x86_64                                                                    5/6 
  Running scriptlet: docker-ce-rootless-extras-27.0.3-1.el9.x86_64                                                                    5/6 
  Installing       : docker-ce-3:27.0.3-1.el9.x86_64                                                                                  6/6 
  Running scriptlet: docker-ce-3:27.0.3-1.el9.x86_64                                                                                  6/6 
  Verifying        : containerd.io-1.7.18-3.1.el9.x86_64                                                                              1/6 
  Verifying        : docker-buildx-plugin-0.15.1-1.el9.x86_64                                                                         2/6 
  Verifying        : docker-ce-3:27.0.3-1.el9.x86_64                                                                                  3/6 
  Verifying        : docker-ce-cli-1:27.0.3-1.el9.x86_64                                                                              4/6 
  Verifying        : docker-ce-rootless-extras-27.0.3-1.el9.x86_64                                                                    5/6 
  Verifying        : docker-compose-plugin-2.28.1-1.el9.x86_64                                                                        6/6 

Installed:
  containerd.io-1.7.18-3.1.el9.x86_64     docker-buildx-plugin-0.15.1-1.el9.x86_64          docker-ce-3:27.0.3-1.el9.x86_64              
  docker-ce-cli-1:27.0.3-1.el9.x86_64     docker-ce-rootless-extras-27.0.3-1.el9.x86_64     docker-compose-plugin-2.28.1-1.el9.x86_64    

Complete!

Step 4: After installation has completed, start and enable the Docker daemon by using the following command.

 [root@linuxhelp ~]# systemctl start docker
 [root@linuxhelp ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

Step 5: Now check the status of docker by using the following command.

[root@linuxhelp ~]# systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: disabled)
     Active: active (running) since Tue 2024-07-02 00:22:59 IST; 25s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 14980 (dockerd)
      Tasks: 10
     Memory: 24.0M
        CPU: 181ms
     CGroup: /system.slice/docker.service
             └─14980 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jul 02 00:22:58 linuxhelp dockerd[14980]: time="2024-07-02T00:22:58.299769604+05:30" level=info msg="Starting up"
Jul 02 00:22:58 linuxhelp dockerd[14980]: time="2024-07-02T00:22:58.353038321+05:30" level=info msg="Loading containers: start."
Jul 02 00:22:58 linuxhelp dockerd[14980]: time="2024-07-02T00:22:58.401530274+05:30" level=info msg="Firewalld: created docker-forwarding>
Jul 02 00:22:59 linuxhelp dockerd[14980]: time="2024-07-02T00:22:59.404722016+05:30" level=info msg="Firewalld: interface docker0 already>
Jul 02 00:22:59 linuxhelp dockerd[14980]: time="2024-07-02T00:22:59.612210788+05:30" level=info msg="Loading containers: done."
Jul 02 00:22:59 linuxhelp dockerd[14980]: time="2024-07-02T00:22:59.628450100+05:30" level=warning msg="Not using native diff for overlay>
Jul 02 00:22:59 linuxhelp dockerd[14980]: time="2024-07-02T00:22:59.628574306+05:30" level=info msg="Docker daemon" commit=662f78c contai>
Jul 02 00:22:59 linuxhelp dockerd[14980]: time="2024-07-02T00:22:59.628766926+05:30" level=info msg="Daemon has completed initialization"
Jul 02 00:22:59 linuxhelp dockerd[14980]: time="2024-07-02T00:22:59.670022342+05:30" level=info msg="API listen on /run/docker.sock"
Jul 02 00:22:59 linuxhelp systemd[1]: Started Docker Application Container Engine.

Step 6: Install git and download for LAMP stack

[root@linuxhelp ~]# dnf install git
Last metadata expiration check: 0:00:35 ago on Tuesday 02 July 2024 12:23:10 AM.
Dependencies resolved.
==========================================================================================================================================
 Package                             Architecture              Version                             Repository                        Size
==========================================================================================================================================
Installing:
 git                                 x86_64                    2.43.5-1.el9_4                      ol9_appstream                     66 k
Installing dependencies:
 git-core                            x86_64                    2.43.5-1.el9_4                      ol9_appstream                    4.5 M
 git-core-doc                        noarch                    2.43.5-1.el9_4                      ol9_appstream                    3.9 M
 perl-Error                          noarch                    1:0.17029-7.el9                     ol9_appstream                     57 k
 perl-Git                            noarch                    2.43.5-1.el9_4                      ol9_appstream                     43 k
 perl-TermReadKey                    x86_64                    2.38-11.el9                         ol9_appstream                     42 k

Transaction Summary
==========================================================================================================================================
Install  6 Packages

Total download size: 8.6 M
Installed size: 37 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): git-2.43.5-1.el9_4.x86_64.rpm                                                                      399 kB/s |  66 kB     00:00    
(2/6): perl-Error-0.17029-7.el9.noarch.rpm                                                                3.2 MB/s |  57 kB     00:00    
(3/6): perl-Git-2.43.5-1.el9_4.noarch.rpm                                                                 2.2 MB/s |  43 kB     00:00    
(4/6): perl-TermReadKey-2.38-11.el9.x86_64.rpm                                                            2.2 MB/s |  42 kB     00:00    
(5/6): git-core-doc-2.43.5-1.el9_4.noarch.rpm                                                              13 MB/s | 3.9 MB     00:00    
(6/6): git-core-2.43.5-1.el9_4.x86_64.rpm                                                                  10 MB/s | 4.5 MB     00:00    
------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                      20 MB/s | 8.6 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                  1/1 
  Installing       : git-core-2.43.5-1.el9_4.x86_64                                                                                   1/6 
  Installing       : git-core-doc-2.43.5-1.el9_4.noarch                                                                               2/6 
  Installing       : perl-TermReadKey-2.38-11.el9.x86_64                                                                              3/6 
  Installing       : perl-Error-1:0.17029-7.el9.noarch                                                                                4/6 
  Installing       : perl-Git-2.43.5-1.el9_4.noarch                                                                                   5/6 
  Installing       : git-2.43.5-1.el9_4.x86_64                                                                                        6/6 
  Running scriptlet: git-2.43.5-1.el9_4.x86_64                                                                                        6/6 
  Verifying        : git-2.43.5-1.el9_4.x86_64                                                                                        1/6 
  Verifying        : git-core-2.43.5-1.el9_4.x86_64                                                                                   2/6 
  Verifying        : git-core-doc-2.43.5-1.el9_4.noarch                                                                               3/6 
  Verifying        : perl-Error-1:0.17029-7.el9.noarch                                                                                4/6 
  Verifying        : perl-Git-2.43.5-1.el9_4.noarch                                                                                   5/6 
  Verifying        : perl-TermReadKey-2.38-11.el9.x86_64                                                                              6/6 

Installed:
  git-2.43.5-1.el9_4.x86_64      git-core-2.43.5-1.el9_4.x86_64      git-core-doc-2.43.5-1.el9_4.noarch perl-Error-1:0.17029-7.el9.noarch
  perl-Git-2.43.5-1.el9_4.noarch perl-TermReadKey-2.38-11.el9.x86_64

Complete!

Step 7: Clone the LAMP from github by using “git clone” command.

[root@linuxhelp ~]# cd /
 [root@linuxhelp /]# git clone https://github.com/jcavat/docker-lamp.git
Cloning into 'docker-lamp'...
remote: Enumerating objects: 93, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 93 (delta 0), reused 1 (delta 0), pack-reused 90
Receiving objects: 100% (93/93), 15.69 KiB | 502.00 KiB/s, done.
Resolving deltas: 100% (37/37), done.

Step 8: Long list the file and verify the downloaded LAMP directory.

[root@linuxhelp /]# ll
total 28
dr-xr-xr-x.   2 root root    6 Jan 10  2022 afs
lrwxrwxrwx.   1 root root    7 Jan 10  2022 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 Feb 19 04:02 boot
drwxr-xr-x.  20 root root 3480 Feb 19 04:02 dev
drwxr-xr-x.   6 root root  129 Jul  2 00:24 docker-lamp
drwxr-xr-x. 138 root root 8192 Jul  2 00:23 etc
drwxr-xr-x.   3 root root   23 Jan  7 03:09 home
lrwxrwxrwx.   1 root root    7 Jan 10  2022 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 Jan 10  2022 lib64 -> usr/lib64
drwxr-xr-x.   2 root root    6 Jan 10  2022 media
drwxr-xr-x.   3 root root   18 Jan  7 02:50 mnt
drwxr-xr-x.   3 root root   24 Jul  2 00:22 opt
dr-xr-xr-x. 327 root root    0 Feb 19 04:01 proc
dr-xr-x---.  15 root root 4096 Jul  2 00:23 root
drwxr-xr-x.  49 root root 1320 Jul  2 00:22 run
lrwxrwxrwx.   1 root root    8 Jan 10  2022 sbin -> usr/sbin
drwxr-xr-x.   2 root root    6 Jan 10  2022 srv
dr-xr-xr-x.  13 root root    0 Feb 19 04:01 sys
drwxrwxrwt.  15 root root 4096 Jul  2 00:23 tmp
drwxr-xr-x.  12 root root  144 Jan  7 02:44 usr
drwxr-xr-x.  20 root root 4096 Jan  7 03:08 var

Step 9: Now go to the LAMP directory and long list the LAMP files by using following commands.

[root@linuxhelp /]# cd docker-lamp/
[root@linuxhelp docker-lamp]# ll
total 16
drwxr-xr-x. 2 root root   22 Jul  2 00:24 conf
-rw-r--r--. 1 root root  974 Jul  2 00:24 docker-compose.yml
-rw-r--r--. 1 root root  291 Jul  2 00:24 Dockerfile
drwxr-xr-x. 2 root root   22 Jul  2 00:24 dump
-rw-r--r--. 1 root root 1210 Jul  2 00:24 LICENSE
-rw-r--r--. 1 root root  615 Jul  2 00:24 README.md
drwxr-xr-x. 2 root root   23 Jul  2 00:24 www

Step 10: Open “docker-compose.yml” file and verify the version and port number for LAMP then save and quit from the file.

[root@linuxhelp docker-lamp]# vim docker-compose.yml 

Step 11: Next open “Dockerfile” and verify the installation command for LAMP then save and quit from the file.

[root@linuxhelp docker-lamp]# vim Dockerfile

Step 12: Now go the document root location inside the LAMP directory.

[root@linuxhelp docker-lamp]# cd www/

Step 13: We can keep our web files in www directory.

[root@linuxhelp www]# vim index.php 

Step 14: Now use the docker compose command to pull images and create containers and required networks for that go to LAMP directory by using the following commands.

 [root@linuxhelp docker-lamp]# docker compose up -d
WARN[0000] /docker-lamp/docker-compose.yml: `version` is obsolete 
[+] Running 31/20
 ✔ db Pulled                                                                                                                        34.0s 
 ✔ phpmyadmin Pulled                                                                                                                28.0s                                                                                                                                                                                                                                                                               
[+] Building 73.6s (8/8) FINISHED                                                                                          docker:default
 => [www internal] load build definition from Dockerfile                                                                             0.0s
 => => transferring dockerfile: 387B                                                                                                 0.0s
 => [www internal] load metadata for docker.io/library/php:7.2-apache                                                                2.6s
 => [www internal] load .dockerignore                                                                                                0.0s
 => => transferring context: 2B                                                                                                      0.0s
 => [www 1/4] FROM docker.io/library/php:7.2-apache@sha256:4dc0f0115acf8c2f0df69295ae822e49f5ad5fe849725847f15aa0e5802b55f8         17.9s
 => => resolve docker.io/library/php:7.2-apache@sha256:4dc0f0115acf8c2f0df69295ae822e49f5ad5fe849725847f15aa0e5802b55f8              0.0s
 => => sha256:6ec7b7d162b24bd6df88abde89ceb6d7bbc2be927f025c9dd061af2b0c328cfe 27.10MB / 27.10MB                                     3.1s
 => => sha256:4dc0f0115acf8c2f0df69295ae822e49f5ad5fe849725847f15aa0e5802b55f8 1.65kB / 1.65kB                                       0.0s
 => => sha256:25417b6c9c2e1a52b551ba89087f4d07c216f58784773c9e7a1710a1f6e2b4a1 3.24kB / 3.24kB                                       0.0s
 => => sha256:c61d277263e19d2ce30a6bae41115c811eb0f9274a601a5e3ee621e54c8a74f7 13.18kB / 13.18kB                                     0.0s
 => => sha256:db606474d60ce31604505c7d6dad9a66cb42f3818fca738832db2f2091cf89c9 225B / 225B                                           0.9s
 => => sha256:afb30f0cd8e0ff78b5eecdc2d9365a50441ad83c5db5f1e87942d6426237fa56 76.65MB / 76.65MB                                     5.1s
 => => sha256:3bb2e805159413e5278b859f7fbb86ddfc99e667cb705d5d5aec0a7c8ffcf1b5 225B / 225B                                           1.4s
 => => sha256:4c761b44e2ccbff3f10b254b21bb00a52dfd26919ad9e3f7efcd569196e6c26b 18.68MB / 18.68MB                                     4.4s
 => => extracting sha256:6ec7b7d162b24bd6df88abde89ceb6d7bbc2be927f025c9dd061af2b0c328cfe                                            2.3s
 => => sha256:c2199db96575122fd559c29b619a2773fe9069e0266312a6369ac95f4464b1dd 434B / 434B                                           3.6s
 => => sha256:1b9a9381eea8f93068e8043f18ea59b709c07256e2f90962931a1433fbdf5e79 487B / 487B                                           4.2s
 => => sha256:fd07bbc59d347c16686f107676436a2281e4128033f105ca7a602aa195bcbe04 12.65MB / 12.65MB                                     5.0s
 => => sha256:72b73ab27698b55aa309173abd0cdd758291b9feaac31342c48ff12f3be14876 494B / 494B                                           5.0s
 => => sha256:6c13f026e6da09e10ca2edb704b335a62bac29e549a2d0b35e535c9aa8dbeeba 2.27kB / 2.27kB                                       5.6s
 => => sha256:983308f4f0d6304dc6cecde8fd66ba5a94a08873a3b8205eb5ff1ea98b419dbc 13.82MB / 13.82MB                                     7.0s
 => => sha256:e5e6cd16368920e691da5b8791184d7a8d579dd5cd5e8c533ad2bf0b82c2d0fc 248B / 248B                                           6.5s
 => => extracting sha256:db606474d60ce31604505c7d6dad9a66cb42f3818fca738832db2f2091cf89c9                                            0.0s
 => => extracting sha256:afb30f0cd8e0ff78b5eecdc2d9365a50441ad83c5db5f1e87942d6426237fa56                                            4.3s
 => => sha256:5c5516e56582a30bd2e69c32d17a169ed7227900318e9d7b5949c8fb447308f5 210B / 210B                                           6.2s
 => => sha256:154729f6ba8609ef7d5af1bfad81efe814cbbca18509834908735c9aced174d3 897B / 897B                                           6.7s
 => => extracting sha256:3bb2e805159413e5278b859f7fbb86ddfc99e667cb705d5d5aec0a7c8ffcf1b5                                            0.0s
 => => extracting sha256:4c761b44e2ccbff3f10b254b21bb00a52dfd26919ad9e3f7efcd569196e6c26b                                            0.8s
 => => extracting sha256:c2199db96575122fd559c29b619a2773fe9069e0266312a6369ac95f4464b1dd                                            0.0s
 => => extracting sha256:1b9a9381eea8f93068e8043f18ea59b709c07256e2f90962931a1433fbdf5e79                                            0.0s
 => => extracting sha256:fd07bbc59d347c16686f107676436a2281e4128033f105ca7a602aa195bcbe04                                            0.1s
 => => extracting sha256:72b73ab27698b55aa309173abd0cdd758291b9feaac31342c48ff12f3be14876                                            0.0s
 => => extracting sha256:983308f4f0d6304dc6cecde8fd66ba5a94a08873a3b8205eb5ff1ea98b419dbc                                            0.7s
 => => extracting sha256:6c13f026e6da09e10ca2edb704b335a62bac29e549a2d0b35e535c9aa8dbeeba                                            0.0s
 => => extracting sha256:e5e6cd16368920e691da5b8791184d7a8d579dd5cd5e8c533ad2bf0b82c2d0fc                                            0.0s
 => => extracting sha256:5c5516e56582a30bd2e69c32d17a169ed7227900318e9d7b5949c8fb447308f5                                            0.0s
 => => extracting sha256:154729f6ba8609ef7d5af1bfad81efe814cbbca18509834908735c9aced174d3                                            0.0s
 => [www 2/4] RUN a2enmod rewrite                                                                                                    0.2s
 => [www 3/4] RUN docker-php-ext-install pdo pdo_mysql                                                                              12.4s
 => [www 4/4] RUN apt-get update     && apt-get install -y libzip-dev     && apt-get install -y zlib1g-dev     && rm -rf /var/lib/  39.9s
 => [www] exporting to image                                                                                                         0.6s
 => => exporting layers                                                                                                              0.6s
 => => writing image sha256:54e27bb5ed7e1ef098aec63d00c63434859e1f3d3f120f39263c692615daf92b                                         0.0s
 => => naming to docker.io/library/docker-lamp-www                                                                                   0.0s
[+] Running 5/5
 ✔ Network docker-lamp_default         Created                                                                                       0.4s 
 ✔ Volume "docker-lamp_persistent"     Created                                                                                       0.0s 
 ✔ Container docker-lamp-db-1          Started                                                                                       0.4s 
 ✔ Container docker-lamp-www-1         Started                                                                                       0.9s 
 ✔ Container docker-lamp-phpmyadmin-1  Started                                                                                       0.8s

Step 15: Check the Container status by using the following command.

 [root@linuxhelp docker-lamp]# docker ps -a
CONTAINER ID   IMAGE                   COMMAND                  CREATED          STATUS          PORTS                                                  NAMES
f2b9488b9b78   phpmyadmin/phpmyadmin   "/docker-entrypoint.…"   17 seconds ago   Up 16 seconds   0.0.0.0:8000->80/tcp, :::8000->80/tcp                  docker-lamp-phpmyadmin-1
228ec58b8646   docker-lamp-www         "docker-php-entrypoi…"   17 seconds ago   Up 16 seconds   0.0.0.0:8001->80/tcp, :::8001->80/tcp                  docker-lamp-www-1
21e7d947d01c   mysql:8.0               "docker-entrypoint.s…"   17 seconds ago   Up 16 seconds   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   docker-lamp-db-1

Step 16: Now go the web browser and check the LAMP Service Status by using our server ip address with LAMP Service ports.

•	phpmyadmin: 8000
•	Apache: 8001
•	mysql: 3306
http://<IP Address>:8000

Snap1

Snap2

http://<IP Address>:8001

Snap3

http://<IP Address>:3306

Snap4

Step 17: Now you can change MySQL password for that Login MySQL container and change DB root password by using the following command.

[root@linuxhelp docker-lamp]# docker compose exec db mysql -u root -p
WARN[0000] /docker-lamp/docker-compose.yml: `version` is obsolete 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 8.0.36 MySQL Community Server - GPL

Copyright (c) 2000, 2024, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| myDb               |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Linuxhelp@123';
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> \q
Bye

Step 18: If you want to stop containers, run the below command

 [root@linuxhelp docker-lamp]# docker compose down
WARN[0000] /docker-lamp/docker-compose.yml: `version` is obsolete 
[+] Running 4/4
 ✔ Container docker-lamp-www-1         Removed                                                                 2.3s 
 ✔ Container docker-lamp-phpmyadmin-1  Removed                                                                 3.1s 
 ✔ Container docker-lamp-db-1          Removed                                                                 2.5s 
 ✔ Network docker-lamp_default         Removed                                                                 1.4s 

Step 19: Now check the container status by using the following command.

 [root@linuxhelp docker-lamp]# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
Now the containers are not in running state.

Conclusion :

We have reached the end of this article. In this guide, we have walked you through the steps required to setup LAMP stack on Docker with Oracle Linux 9.3. Your feedback is much welcome.

Tags:
matthew
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

Why do we use Docker for LAMP development?

A

Docker provides a lightweight and portable way to package and run applications. Using Docker for a LAMP stack ensures consistency across different environments and simplifies deployment.

Q

Where can I find pre-built Docker images for LAMP components?

A

Docker Hub offers a variety of pre-built images for Apache, PHP, and MySQL. These images can be easily pulled and used in your Docker environment.

Q

Do I need to create custom Dockerfiles for Apache, PHP, and MySQL?

A

While you can use pre-built images, custom Dockerfiles allow you to tailor configurations and dependencies to your specific needs. You can create Dockerfiles to install additional packages or configure settings.

Q

How do I access my Dockerized LAMP stack on Rocky Linux?

A

Once your Docker containers are running, you can access your LAMP stack by navigating to http://localhost in your web browser. Docker Compose handles the networking and port mapping for you.

Q

What is Docker Compose, and how does it relate to LAMP stacks?

A

Docker Compose is a tool for defining and running multi-container Docker applications. You can use Docker Compose to manage your LAMP stack's services, networks, and volumes in a single configuration file (docker-compose.yml).

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Luke ?
workbench for debian

I am using workbench in CentOS whereas now I need to use Debian Operating system so could you please help to install and use in Debian?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.