Skip to content

Commit 4a4afd9

Browse files
authored
Merge pull request docker-library#2552 from felipementel/feature/mariadb-readme-update
docs: update readme from mariadb with port binding, tags, remove double spaces and informations
2 parents 610abd9 + 0db1572 commit 4a4afd9

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

mariadb/content.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,34 @@ The %%IMAGE%% has a number of tags, and of note is `latest`, as the latest stabl
1212

1313
## Running the container
1414

15+
### Configuration
16+
17+
#### Port binding
18+
19+
By default, the database running within the container will listen on port 3306. You can expose the container port 3306 to the host port 3306 with the `-p 3306:3306` argument to `docker run`, like the command below:
20+
21+
```console
22+
$ docker run --name some-%%REPO%% -p 3306:3306 %%IMAGE%%:latest
23+
```
24+
1525
### Starting using a minimal configuration
1626

1727
The environment variables required to use this image involves the setting of the root user password:
1828

1929
```console
20-
$ docker run --detach --name some-%%REPO%% --env MARIADB_ROOT_PASSWORD=my-secret-pw %%IMAGE%%:latest
30+
$ docker run --detach --name some-%%REPO%% --env MARIADB_ROOT_PASSWORD=my-secret-pw %%IMAGE%%:latest
2131
```
2232

2333
or:
2434

2535
```console
26-
$ docker run --detach --name some-%%REPO%% --env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 %%IMAGE%%:latest
36+
$ docker run --detach --name some-%%REPO%% --env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 %%IMAGE%%:latest
2737
```
2838

2939
or:
3040

3141
```console
32-
$ docker run --detach --name some-%%REPO%% --env MARIADB_RANDOM_ROOT_PASSWORD=1 %%IMAGE%%:latest
42+
$ docker run --detach --name some-%%REPO%% --env MARIADB_RANDOM_ROOT_PASSWORD=1 %%IMAGE%%:latest
3343
```
3444

3545
... where the container logs will contain the generated root password.
@@ -43,7 +53,7 @@ Run `docker compose up`, wait for it to initialize completely, and visit `http:/
4353
Starting a MariaDB instance with a user, password, and a database:
4454

4555
```console
46-
$ docker run --detach --name some-%%REPO%% --env MARIADB_USER=example-user --env MARIADB_PASSWORD=my_cool_secret --env MARIADB_DATABASE=exmple-database --env MARIADB_ROOT_PASSWORD=my-secret-pw %%IMAGE%%:latest
56+
$ docker run --detach --name some-%%REPO%% --env MARIADB_USER=example-user --env MARIADB_PASSWORD=my_cool_secret --env MARIADB_DATABASE=exmple-database --env MARIADB_ROOT_PASSWORD=my-secret-pw %%IMAGE%%:latest
4757
```
4858

4959
### Start a `%%IMAGE%%` server instance in a network
@@ -52,8 +62,8 @@ As applications talk to MariaDB, MariaDB needs to start in the same network as t
5262

5363
```console
5464
$ docker network create some-network
55-
$ docker run --detach --network some-network --name some-%%REPO%% --env MARIADB_USER=example-user --env MARIADB_PASSWORD=my_cool_secret --env MARIADB_ROOT_PASSWORD=my-secret-pw %%IMAGE%%:latest
56-
$ docker run --detach --network some-network --name some-application --env APP_DB_HOST=some-%%REPO%% --env APP_DB_USER=example-user --env APP_DB_PASSWD=my_cool_secret some-application
65+
$ docker run --detach --network some-network --name some-%%REPO%% --env MARIADB_USER=example-user --env MARIADB_PASSWORD=my_cool_secret --env MARIADB_ROOT_PASSWORD=my-secret-pw %%IMAGE%%:latest
66+
$ docker run --detach --network some-network --name some-application --env APP_DB_HOST=some-%%REPO%% --env APP_DB_USER=example-user --env APP_DB_PASSWD=my_cool_secret some-application
5767
```
5868

5969
... where `some-network` is a newly created network (other than `bridge` as the default network), `some-%%REPO%%` is the name you want to assign to your container, `my-secret-pw` is the password to be set for the MariaDB root user. See the list above for relevant tags to match your needs and environment. `some-application` and then environment variable `APP_DB_HOST`, `APP_DB_USER` and `APP_DB_PASSWD` are the application's configuration for its database connection.
@@ -63,7 +73,7 @@ $ docker run --detach --network some-network --name some-application --env APP_D
6373
The following command starts another `%%IMAGE%%` container instance and runs the `mariadb` command line client against your original `%%IMAGE%%` container, allowing you to execute SQL statements against your database instance:
6474

6575
```console
66-
$ docker run -it --network some-network --rm %%IMAGE%% mariadb -hsome-%%REPO%% -uexample-user -p
76+
$ docker run -it --network some-network --rm %%IMAGE%% mariadb -h some-%%REPO%% -u example-user
6777
```
6878

6979
... where `some-%%REPO%%` is the name of your original `%%IMAGE%%` container (connected to the `some-network` Docker network).

0 commit comments

Comments
 (0)