How to Build a Lamp Stack Docker Container on Ubuntu 21.04
- 00:37 lsb_release -a
- 00:45 docker create ubuntu:latest
- 01:17 docker run --name lamp -it ubuntu
- 01:54 apt update
- 02:07 apt install apache2 -y
- 02:26 apt install mariadb-server -y
- 02:56 apt install php php-cgi php-common php-curl php-mbstring php-gd php-mysql php-zip php-xml php-imap php-json php-snmp php-fpm libapache2-mod-php -y
- 03:13 exit
- 03:20 docker container commit e90093d14b76 ubuntu
- 04:13 docker images
- 04:26 docker login -u aravindhanpspa
- 05:01 docker image tag ubuntu:latest aravindhanpspa/lamp
- 05:31 docker image push aravindhanpspa/lamp
To Build a Lamp Stack Docker Container on Ubuntu 21.04
Introduction:
Docker is a software platform that enables rapid development, testing, and deployment of applications. LAMP (Linux, Apache, MySQL, PHP/Perl/Python) is one of the most common stacks of solutions used in many popular web applications.
Installation Procedure:
Step 1: Check the OS version by using the below command
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.04
Release: 21.04
Codename: hirsute
Step 2: Create a Ubuntu Docker Image from official Docker Hub by using the below command
root@linuxhelp:~# docker create ubuntu:latest
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
ea362f368469: Pull complete
Digest: sha256:b5a61709a9a44284d88fb12e5c48db0409cfad5b69d4ff8224077c57302df9cf
Status: Downloaded newer image for ubuntu:latest
82c76cbbe65befd9d5e60923aa71a27ed856a86b37d6f756f444065e411a8ff7
Step 3: Run the Ubuntu container with shell execution by using the below command
root@linuxhelp:~# docker run --name lamp -it ubuntu
Step 4: Update the apt source list by using the below command
root@e90093d14b76:/# apt update
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [889 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [30.1 kB]
Reading package lists... Done
Building dependency tree
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
Step 5: Install Apache Web Server by using the below command
root@e90093d14b76:/# apt install apache2 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils ca-certificates file krb5-locales libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap libasn1-8-heimdal libbrotli1 libcurl4 libexpat1 libgdbm-compat4 libgdbm6
libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal
libhx509-5-heimdal libicu66 libjansson4 libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Step 6: Installing MariaDB Server by using the below command
root@e90093d14b76:/# apt install mariadb-server -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
galera-3 gawk iproute2 libaio1 libatm1 libbsd0 libcap2 libcap2-bin libcgi-fast-perl libcgi-pm-perl
invoke-rc.d: policy-rc.d denied execution of start.
Setting up libcgi-fast-perl (1:2.15-1) ...
Setting up mariadb-server (1:10.3.32-0ubuntu0.20.04.1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Step 7: Install PHP and its Modules by using the below command
root@e90093d14b76:/# apt install php php-cgi php-common php-curl php-mbstring php-gd php-mysql php-zip php-xml php-imap php-json php-snmp php-fpm libapache2-mod-php -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
dbus dmsetup fontconfig-config fonts-dejavu-core gir1.2-glib-2.0 libapache2-mod-php7.4 libapparmor1 libargon2-1
NOTICE: Not enabling PHP 7.4 FPM by default.
NOTICE: To enable PHP 7.4 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.4-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Step 8:Exit from the Containers Shell
root@e90093d14b76:/# exit
exit
Step 9: Commit the Container before pushing to the repository by using the below command
root@linuxhelp:~# docker container commit e90093d14b76 ubuntu
sha256:ddae6eba5b358716a656126a3a237757dacf8f5d6dca59549bd5caad44ee87a0
Step 10: Viewing the Docker images by using the below command
root@linuxhelp:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest ddae6eba5b35 7 seconds ago 617MB
ubuntu <none> d13c942271d6 12 days ago 72.8MB
Step 11: Login to the Docker hub by using the below command
root@linuxhelp:~# docker login -u aravindhanpspa
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
Step 12: Create a tag for the image before push by using the below command
root@linuxhelp:~# docker image tag ubuntu:latest aravindhanpspa/lamp
Step 13: Push the image to the repository by using the below command
root@linuxhelp:~# docker image push aravindhanpspa/lamp
Using default tag: latest
The push refers to repository [docker.io/aravindhanpspa/lamp]
13a197fbb6a7: Pushed
0eba131dffd0: Mounted from library/ubuntu
latest: digest: sha256:b2b0a9da9ee6f077f19ee29a907b763ab507fa93a14d6218e607d453dc11fbb2 size: 742
Step 14: Login to the Docker Hub as show in the below image
Step 15: Repository of the pushed image as shown in the below image
By this to build a Lamp Stack Docker Container on Ubuntu 21.04 have been completed.
Comments ( 0 )
No comments available