mirror of
https://github.com/bitnami/containers.git
synced 2026-03-21 15:29:05 +08:00
@@ -15,9 +15,14 @@ docker run --name mariadb bitnami/mariadb:latest
|
|||||||
|
|
||||||
## Docker Compose
|
## Docker Compose
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
mariadb:
|
version: '2'
|
||||||
image: bitnami/mariadb:latest
|
|
||||||
|
services:
|
||||||
|
mariadb:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306:3306'
|
||||||
```
|
```
|
||||||
|
|
||||||
# Get this image
|
# Get this image
|
||||||
@@ -58,11 +63,16 @@ docker run -v /path/to/mariadb-persistence:/bitnami/mariadb bitnami/mariadb:late
|
|||||||
|
|
||||||
or using Docker Compose:
|
or using Docker Compose:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
mariadb:
|
version: '2'
|
||||||
image: bitnami/mariadb:latest
|
|
||||||
volumes:
|
services:
|
||||||
- /path/to/mariadb-persistence:/bitnami/mariadb
|
mariadb:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306:3306'
|
||||||
|
volumes:
|
||||||
|
- /path/to/mariadb-persistence:/bitnami/mariadb
|
||||||
```
|
```
|
||||||
|
|
||||||
# Linking
|
# Linking
|
||||||
@@ -106,20 +116,22 @@ docker exec -it mariadb mysql -u root
|
|||||||
|
|
||||||
Copy the snippet below into your `docker-compose.yml` to add MariaDB to your application.
|
Copy the snippet below into your `docker-compose.yml` to add MariaDB to your application.
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
mariadb:
|
services:
|
||||||
image: bitnami/mariadb:latest
|
mariadb:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Link it to another container in your application
|
### Step 2: Link it to another container in your application
|
||||||
|
|
||||||
Update the definitions for containers you want to access your MariaDB server from to include a link to the `mariadb` entry you added in Step 1.
|
Update the definitions for containers you want to access your MariaDB server from to include a link to the `mariadb` entry you added in Step 1.
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
myapp:
|
services:
|
||||||
image: myapp
|
myapp:
|
||||||
links:
|
image: 'myapp'
|
||||||
- mariadb:mariadb
|
depends_on:
|
||||||
|
- mariadb
|
||||||
```
|
```
|
||||||
|
|
||||||
Inside `myapp`, use `mariadb` as the hostname for the MariaDB server.
|
Inside `myapp`, use `mariadb` as the hostname for the MariaDB server.
|
||||||
@@ -136,11 +148,16 @@ docker run --name mariadb -e MARIADB_ROOT_PASSWORD=password123 bitnami/mariadb:l
|
|||||||
|
|
||||||
or using Docker Compose:
|
or using Docker Compose:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
mariadb:
|
version: '2'
|
||||||
image: bitnami/mariadb:latest
|
|
||||||
environment:
|
services:
|
||||||
- MARIADB_ROOT_PASSWORD=password123
|
mariadb:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306:3306'
|
||||||
|
environment:
|
||||||
|
- MARIADB_ROOT_PASSWORD=password123
|
||||||
```
|
```
|
||||||
|
|
||||||
**Warning** The `root` user is always created with remote access. It's suggested that the `MARIADB_ROOT_PASSWORD` env variable is always specified to set a password for the `root` user.
|
**Warning** The `root` user is always created with remote access. It's suggested that the `MARIADB_ROOT_PASSWORD` env variable is always specified to set a password for the `root` user.
|
||||||
@@ -155,11 +172,16 @@ docker run --name mariadb -e MARIADB_DATABASE=my_database bitnami/mariadb:latest
|
|||||||
|
|
||||||
or using Docker Compose:
|
or using Docker Compose:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
mariadb:
|
version: '2'
|
||||||
image: bitnami/mariadb:latest
|
|
||||||
environment:
|
services:
|
||||||
- MARIADB_DATABASE=my_database
|
mariadb:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306:3306'
|
||||||
|
environment:
|
||||||
|
- MARIADB_DATABASE=my_database
|
||||||
```
|
```
|
||||||
|
|
||||||
## Creating a database user on first run
|
## Creating a database user on first run
|
||||||
@@ -175,13 +197,18 @@ docker run --name mariadb \
|
|||||||
|
|
||||||
or using Docker Compose:
|
or using Docker Compose:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
mariadb:
|
version: '2'
|
||||||
image: bitnami/mariadb:latest
|
|
||||||
environment:
|
services:
|
||||||
- MARIADB_USER=my_user
|
mariadb:
|
||||||
- MARIADB_PASSWORD=my_password
|
image: 'bitnami/mariadb:latest'
|
||||||
- MARIADB_DATABASE=my_database
|
ports:
|
||||||
|
- '3306:3306'
|
||||||
|
environment:
|
||||||
|
- MARIADB_USER=my_user
|
||||||
|
- MARIADB_PASSWORD=my_password
|
||||||
|
- MARIADB_DATABASE=my_database
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note!** The `root` user will still be created with remote access. Please ensure that you have specified a password for the `root` user using the `MARIADB_ROOT_PASSWORD` env variable.
|
**Note!** The `root` user will still be created with remote access. Please ensure that you have specified a password for the `root` user using the `MARIADB_ROOT_PASSWORD` env variable.
|
||||||
@@ -246,38 +273,47 @@ You now have a two node MariaDB master/slave replication cluster up and running.
|
|||||||
With Docker Compose the master/slave replication can be setup using:
|
With Docker Compose the master/slave replication can be setup using:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
master:
|
version: '2'
|
||||||
image: bitnami/mariadb:latest
|
|
||||||
environment:
|
|
||||||
- MARIADB_ROOT_PASSWORD=root_password
|
|
||||||
- MARIADB_REPLICATION_MODE=master
|
|
||||||
- MARIADB_REPLICATION_USER=my_repl_user
|
|
||||||
- MARIADB_REPLICATION_PASSWORD=my_repl_password
|
|
||||||
- MARIADB_USER=my_user
|
|
||||||
- MARIADB_PASSWORD=my_password
|
|
||||||
- MARIADB_DATABASE=my_database
|
|
||||||
|
|
||||||
slave:
|
services:
|
||||||
image: bitnami/mariadb:latest
|
mariadb-master:
|
||||||
links:
|
image: 'bitnami/mariadb:latest'
|
||||||
- master:master
|
ports:
|
||||||
environment:
|
- '3306'
|
||||||
- MARIADB_ROOT_PASSWORD=root_password
|
volumes:
|
||||||
- MARIADB_REPLICATION_MODE=slave
|
- /path/to/mariadb-persistence:/bitnami/mariadb
|
||||||
- MARIADB_REPLICATION_USER=my_repl_user
|
environment:
|
||||||
- MARIADB_REPLICATION_PASSWORD=my_repl_password
|
- MARIADB_REPLICATION_MODE=master
|
||||||
- MARIADB_MASTER_HOST=master
|
- MARIADB_REPLICATION_USER=repl_user
|
||||||
- MARIADB_MASTER_USER=my_user
|
- MARIADB_REPLICATION_PASSWORD=repl_password
|
||||||
- MARIADB_MASTER_PASSWORD=my_password
|
- MARIADB_ROOT_PASSWORD=root_password
|
||||||
- MARIADB_USER=my_user
|
- MARIADB_USER=my_user
|
||||||
- MARIADB_PASSWORD=my_password
|
- MARIADB_PASSWORD=my_password
|
||||||
- MARIADB_DATABASE=my_database
|
- MARIADB_DATABASE=my_database
|
||||||
|
mariadb-slave:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306'
|
||||||
|
depends_on:
|
||||||
|
- mariadb-master
|
||||||
|
environment:
|
||||||
|
- MARIADB_REPLICATION_MODE=slave
|
||||||
|
- MARIADB_REPLICATION_USER=repl_user
|
||||||
|
- MARIADB_REPLICATION_PASSWORD=repl_password
|
||||||
|
- MARIADB_MASTER_HOST=mariadb-master
|
||||||
|
- MARIADB_MASTER_PORT=3306
|
||||||
|
- MARIADB_MASTER_USER=my_user
|
||||||
|
- MARIADB_MASTER_PASSWORD=my_password
|
||||||
|
- MARIADB_ROOT_PASSWORD=root_password
|
||||||
|
- MARIADB_USER=my_user
|
||||||
|
- MARIADB_PASSWORD=my_password
|
||||||
|
- MARIADB_DATABASE=my_database
|
||||||
```
|
```
|
||||||
|
|
||||||
Scale the number of slaves using:
|
Scale the number of slaves using:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker-compose scale master=1 slave=3
|
docker-compose scale mariadb-master=1 mariadb-slave=3
|
||||||
```
|
```
|
||||||
|
|
||||||
The above command scales up the number of slaves to `3`. You can scale down in the same manner.
|
The above command scales up the number of slaves to `3`. You can scale down in the same manner.
|
||||||
@@ -298,11 +334,16 @@ docker run --name mariadb -v /path/to/mariadb-persistence:/bitnami/mariadb bitna
|
|||||||
|
|
||||||
or using Docker Compose:
|
or using Docker Compose:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
mariadb:
|
version: '2'
|
||||||
image: bitnami/mariadb:latest
|
|
||||||
volumes:
|
services:
|
||||||
- /path/to/mariadb-persistence:/bitnami/mariadb
|
mariadb:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306:3306'
|
||||||
|
volumes:
|
||||||
|
- /path/to/mariadb-persistence:/bitnami/mariadb
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Edit the configuration
|
### Step 2: Edit the configuration
|
||||||
@@ -391,11 +432,16 @@ docker run -v /path/to/mariadb-backups/latest:/bitnami/mariadb bitnami/mariadb:l
|
|||||||
|
|
||||||
or using Docker Compose:
|
or using Docker Compose:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
mariadb:
|
version: '2'
|
||||||
image: bitnami/mariadb:latest
|
|
||||||
volumes:
|
services:
|
||||||
- /path/to/mariadb-backups/latest:/bitnami/mariadb
|
mariadb:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306:3306'
|
||||||
|
volumes:
|
||||||
|
- /path/to/mariadb-backups/latest:/bitnami/mariadb
|
||||||
```
|
```
|
||||||
|
|
||||||
## Upgrade this image
|
## Upgrade this image
|
||||||
|
|||||||
35
bitnami/mariadb/docker-compose-replication.yml
Normal file
35
bitnami/mariadb/docker-compose-replication.yml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
mariadb-master:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306'
|
||||||
|
volumes:
|
||||||
|
- 'mariadb_master_data:/bitnami/mariadb'
|
||||||
|
environment:
|
||||||
|
- MARIADB_REPLICATION_MODE=master
|
||||||
|
- MARIADB_REPLICATION_USER=repl_user
|
||||||
|
- MARIADB_REPLICATION_PASSWORD=repl_password
|
||||||
|
- MARIADB_USER=my_user
|
||||||
|
- MARIADB_PASSWORD=my_password
|
||||||
|
- MARIADB_DATABASE=my_database
|
||||||
|
mariadb-slave:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306'
|
||||||
|
depends_on:
|
||||||
|
- mariadb-master
|
||||||
|
environment:
|
||||||
|
- MARIADB_REPLICATION_MODE=slave
|
||||||
|
- MARIADB_REPLICATION_USER=repl_user
|
||||||
|
- MARIADB_REPLICATION_PASSWORD=repl_password
|
||||||
|
- MARIADB_MASTER_HOST=mariadb-master
|
||||||
|
- MARIADB_MASTER_PORT=3306
|
||||||
|
- MARIADB_USER=my_user
|
||||||
|
- MARIADB_PASSWORD=my_password
|
||||||
|
- MARIADB_DATABASE=my_database
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mariadb_master_data:
|
||||||
|
driver: local
|
||||||
13
bitnami/mariadb/docker-compose.yml
Normal file
13
bitnami/mariadb/docker-compose.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
mariadb:
|
||||||
|
image: 'bitnami/mariadb:latest'
|
||||||
|
ports:
|
||||||
|
- '3306:3306'
|
||||||
|
volumes:
|
||||||
|
- 'mariadb_data:/bitnami/mariadb'
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mariadb_data:
|
||||||
|
driver: local
|
||||||
Reference in New Issue
Block a user