# MariaDB Container Instance
# Create a new instance
- Log into portainer
https://[vm-ip]:9443 - Make sure you've created a network of type
bridgein portainer calledmdb-managementon theNetworkspage. - Navigate to the
Stackspage and click on+ Add stack - Name the instance and use the following
docker-compose.ymldefinition.- You should change a few things here: hostnmane, host port and root password at least
# docker-compose.yml
version: '2.4'
services:
db:
image: mariadb:10.7.1
restart: always
ports:
- 3306:3306 # host:container
hostname: mdb## # change me
environment:
MYSQL_ROOT_PASSWORD: example # should be removed after initial install
volumes:
- data:/var/lib/mysql
cpus: 0.5
mem_limit: 1g
memswap_limit: 0
volumes:
data:
networks:
default:
external: true
name: mdb-management
Note: You can create an
App Templatewith the docker-compose file for later use
- Click on
Deploy the stack - You should remove the variable
MYSQL_ROOT_PASSWORDafter the initialization. See Change an existing instance for details.
# Change an existing instance
- Log into portainer
https://[vm-ip]:9443 - Navigate to the
Stackspage and click on the Stack you want to change - Click on the
Editor-Tab and change thedocker-compose.ymldefinition to you likings. - Click
Update the stackand you are done
# Creating initial DB User and Database
Connect to the Database using Adminer or any other MySQL client of you choice.
Execute the following SQL Queries:
CREATE SCHEMA [DATABASE NAME];
CREATE USER [USER NAME];@'%' IDENTIFIED BY '[PASSWORD]';
GRANT ALL PRIVILEGES ON [DATABASE NAME].* to [USER NAME]@'%';
Note: Replace the placeholders
[DATABASE NAME],[USER NAME]and[PASSWORD]!