Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mbk-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MBK_Workshop
mbk-framework
Commits
7e1a8206
Commit
7e1a8206
authored
Aug 13, 2024
by
Mohd Al Bukhori bin Zahari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
134 additions
and
0 deletions
+134
-0
readme.md
readme.md
+134
-0
No files found.
readme.md
0 → 100644
View file @
7e1a8206
# Docker Workshop
Lab 1: Docker Compose
---
## Install docker-compose
-
install docker-compose:
```
sudo apt install docker-compose
```
## Preparations
-
Create a new folder for the lab:
```
mkdir lab-11
cd lab-11
```
## Instructions
-
Create a
**"docker-compose.yml"**
file with the content below:
```
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: admin
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: admin
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
```
-
Start all the environment in detached mode:
```
docker-compose up -d
```
-
Wait until docker complete to start the containers, meanwhile let's inspect the wordpress logs:
```
docker-compose logs -f wordpress
```
-
Check the running containers:
```
docker-compose ps
```
-
Browse to the wordpress portal:
```
http://<Your-Server-IP>:8000
```
-
Enter to the mysql container:
```
docker-compose exec db bin/bash
```
-
Print the environment variable
**"MYSQL_USER"**
(passed in the yaml file):
```
echo $MYSQL_USER
```
-
Exit from the container
```
exit
```
-
Update the mysql image used in the
**docker-compose.yml**
file to "5.7.24":
```
image: mysql:5.7.24
```
```
db:
image: mysql:5.7.24
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: admin
MYSQL_PASSWORD: wordpress
```
-
Apply the changes to the running environment:
```
docker-compose up -d
```
-
Let's clean our environment (remove the containers defined in the docker-compose file):
```
docker-compose down
```
-
Note that volumes are not deleted by default, so you can recreate the environment at any time
```
docker volume ls
```
-
To remove the volumes as well you can use "docker-compose down --volume"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment