How to Setup Lamp Stack by Docker Compose on Ubuntu 21.04
To Setup Lamp Stack By Docker Compose On Ubuntu 21.04
Introduction:
The Docker Compose software was created to help define and share multi-container applications. Furthermore, we can use YAML files to define services, and with just a single command, we can start or stop everything.
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: Check the Docker Version by using the below command
root@linuxhelp:~# docker -v
Docker version 20.10.12, build e91ed57
Step 3: Create a directory as docker by using the below command
root@linuxhelp:~# mkdir docker
Step 4: Change to the docker directory by using the below command
root@linuxhelp:~# cd docker/
Step 5: Create a Docker Compose file by using the below command
root@linuxhelp:~/docker# vim docker-compose.yml
version: "3"
services:
web:
image: "httpd"
restart: 'always'
depends_on:
- mariadb
restart: 'always'
ports:
- '8080:80'
links:
- mariadb
mariadb:
image: "mariadb"
restart: 'always'
environment:
MYSQL_ROOT_PASSWORD: linuxc
MYSQL_DATABASE: lamp
MYSQL_USER: luser
MYSQL_PASSWORD: linuxc
php:
image: "php"
restart: 'always'
Step 6: Execute the Docker Compose file by using the below command
root@linuxhelp:~/docker# docker-compose up
Creating network "docker_default" with the default driver
Pulling mariadb (mariadb:)...
latest: Pulling from library/mariadb
08c01a0ec47e: Pull complete
a2bcb14c13a1: Pull complete
29c56760f879: Pull complete
a95000a218fc: Pull complete
a765d76e68d9: Pull complete
c6945738f085: Pull complete
62787b7c58c5: Pull complete
d2987a30cfe4: Pull complete
cbc65983d8b5: Pull complete
db216f91595e: Pull complete
Digest: sha256:ca31f38b6e325ece985d857db7eba1fe59928b4fd83ff8a55cb912c9684b9e43
Status: Downloaded newer image for mariadb:latest
Pulling web (httpd:)...
latest: Pulling from library/httpd
5eb5b503b376: Pull complete
a43a76ccc967: Pull complete
942bd346e7f7: Pull complete
cdb155854ae6: Pull complete
10c4d45228bf: Pull complete
Digest: sha256:5cc947a200524a822883dc6ce6456d852d7c5629ab177dfbf7e38c1b4a647705
Status: Downloaded newer image for httpd:latest
Pulling php (php:)...
latest: Pulling from library/php
5eb5b503b376: Already exists
8b1ad84cf101: Pull complete
38c937dadeb7: Pull complete
6a2f1dc96e59: Pull complete
09f78174268e: Pull complete
789f1e9593c6: Pull complete
cefa19191812: Pull complete
6773fb0526e7: Pull complete
e0dc0a9c3fe9: Pull complete
Digest: sha256:f1d66b530e99d2e3c2ea302523c5a10ae9e666ddb5ceaacb7dda0af20c7976d7
Status: Downloaded newer image for php:latest
Creating docker_php_1 ... done
Creating docker_mariadb_1 ... done
Creating docker_web_1 ... done
Attaching to docker_mariadb_1, docker_php_1, docker_web_1
php_1 | Interactive shell
php_1 |
php_1 | php > mariadb_1 | 2022-02-16 20:49:21+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.5+maria~focal started.
mariadb_1 | 2022-02-16 20:49:22+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mariadb_1 | 2022-02-16 20:49:22+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.5+maria~focal started.
mariadb_1 | 2022-02-16 20:49:22+00:00 [Note] [Entrypoint]: Initializing database files
mariadb_1 | 2022-02-16 20:49:23 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
web_1 | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message
web_1 | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message
web_1 | [Wed Feb 16 20:49:23.865790 2022] [mpm_event:notice] [pid 1:tid 140529800916288] AH00489: Apache/2.4.52 (Unix) configured -- resuming normal operations
web_1 | [Wed Feb 16 20:49:23.874958 2022] [core:notice] [pid 1:tid 140529800916288] AH00094: Command line: 'httpd -D FOREGROUND'
docker_php_1 exited with code 0
mariadb_1 |
mariadb_1 |
mariadb_1 | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
mariadb_1 | To do so, start the server, then issue the following command:
mariadb_1 |
mariadb_1 | '/usr/bin/mysql_secure_installation'
mariadb_1 |
mariadb_1 | which will also give you the option of removing the test
mariadb_1 | databases and anonymous user created by default. This is
mariadb_1 | strongly recommended for production servers.
Step 7: Ping http://localhost:8080 in Browser as shown in the below image
By this to Setup Lamp Stack by Docker Compose on Ubuntu 21.04 have been completed.
Comments ( 0 )
No comments available