• 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 by Docker Compose on Ubuntu 21.04

  • 00:33 lsb_release -a
  • 00:39 docker -v
  • 00:52 mkdir docker
  • 00:59 cd docker/
  • 01:05 vim docker-compose.yml
  • 06:06 docker-compose up
{{postValue.id}}

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 Snap 1

By this to Setup Lamp Stack by Docker Compose on Ubuntu 21.04 have been completed.

Tags:
jackson
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is docker-compose vs Dockerfile?

A

Dockerfile is a simple text file that contains the commands a user could call to assemble an image whereas Docker Compose is a tool for defining and running multi-container Docker applications

Q

How to start up your application by Docker Compose?

A

To start up the application by Docker Compose by using the command

Q

How to run a container in the background?

A

To run a container in the background by using the command

Q

How to run a Docker Compose output in the background?

A

To run a Docker Compose output in the background, using the command

Q

How to remove the data volume of a container?

A

To remove the data volume of a container by using

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 Luk Van De Looverbosch ?
How to create a root ?

Hello,
How to create root@linuxhelp in Linux Mint 20.1 64-bit ?
Thanks in advance for your reply.
Best regards.

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.