• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial 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
6954

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

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

Related Tutorials in How to Setup Lamp Stack by Docker Compose on Ubuntu 21.04

Related Tutorials in How to Setup Lamp Stack by Docker Compose on Ubuntu 21.04

How to install Meld tool in Ubuntu
How to install Meld tool in Ubuntu
Feb 25, 2017
How to install Dconf-Editor on Ubuntu 18.04
How to install Dconf-Editor on Ubuntu 18.04
Jul 14, 2018
How to install and update OpenSSL on Ubuntu 16.04
How to install and update OpenSSL on Ubuntu 16.04
Mar 9, 2017
How to install GLib 2.0 on Ubuntu 17.04
How to install GLib 2.0 on Ubuntu 17.04
May 22, 2017
How to Install Android Emulator on Ubuntu 20.4.1
How to Install Android Emulator on Ubuntu 20.4.1
Jul 13, 2021
How To Install AnyDesk on Ubuntu 16.04
How To Install AnyDesk on Ubuntu 16.04
Apr 4, 2018
How to install Genymotion 2.12.1 on Ubuntu 18.04
How to install Genymotion 2.12.1 on Ubuntu 18.04
Jul 9, 2018
How to install Timeshift 18.4 on Ubuntu 18.04
How to install Timeshift 18.4 on Ubuntu 18.04
Jul 6, 2018

Related Forums in How to Setup Lamp Stack by Docker Compose on Ubuntu 21.04

Related Forums in How to Setup Lamp Stack by Docker Compose on Ubuntu 21.04

Ubuntu
matthew class=
Failed to enable unit: Refusing to operate on linked unit file sshd.service
Apr 15, 2019
Ubuntu
mason class=
Passwd: You may not view or modify password information for root On Ubuntu 19.04
May 27, 2019
Ubuntu
isaac class=
/etc/apt/sources.list Permission denied
May 18, 2017
Ubuntu
yousuf class=
lsb_release command not working : Debian
Jan 18, 2018
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Ubuntu
mason class=
"E: Package 'php-mcrypt' has no installation candidate" error on Ubuntu 20.4.1
Mar 15, 2021
NFS
luke class=
clnt_create: RPC: Program not registered
Apr 25, 2017
Apache
isaac class=
How to disable apache welcome page on Ubuntu
Dec 15, 2018

Related News in How to Setup Lamp Stack by Docker Compose on Ubuntu 21.04

Related News in How to Setup Lamp Stack by Docker Compose on Ubuntu 21.04

How To Install Mixxx on Ubuntu 16.04
How To Install Mixxx on Ubuntu 16.04
Oct 11, 2017
Ubuntu 17.04 released with greater expectations
Ubuntu 17.04 released with greater expectations
Apr 15, 2017
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Mar 1, 2017
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Sep 2, 2017
Ubuntu Unity is no more: One Linux dream has been axed
Ubuntu Unity is no more: One Linux dream has been axed
Apr 7, 2017
What’s next for Ubuntu Linux Desktop?
What’s next for Ubuntu Linux Desktop?
Apr 11, 2017
Say Hi to Ubuntu's new mascot
Say Hi to Ubuntu's new mascot
Mar 22, 2019
KDE Connect App was removed from Google Play Store and brought back in 24 hours
KDE Connect App was removed from Google Play Store and brought back in 24 hours
Mar 22, 2019
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 Lucas ?
Various options in Top command

Am using Top command only to view the load average, what are the various options in Top command..??

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.