Simplify docker networking and clarify the README, fixes #8
This commit is contained in:
parent
34dfc562a9
commit
1a5dc96f0d
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/target
|
||||
config.toml
|
||||
|
14
README.md
14
README.md
@ -15,17 +15,21 @@ Ensure you have a [rust toolchain](https://www.rust-lang.org/tools/install) inst
|
||||
In order to set up a test instance of mariadb in a docker container, run the following command:
|
||||
|
||||
```bash
|
||||
docker run --rm --name mariadb -e MYSQL_ROOT_PASSWORD=secret -d mariadb:latest
|
||||
docker run --rm --name mariadb -e MYSQL_ROOT_PASSWORD=secret -p 3306:3306 -d mariadb:latest
|
||||
```
|
||||
|
||||
You should then create a config file, and adjust the hostname to the IP address of the docker container.
|
||||
This will start a mariadb instance with the root password `secret`, and expose the port 3306 on the host machine.
|
||||
|
||||
|
||||
Run the following command to create a configuration file with the default settings:
|
||||
|
||||
```bash
|
||||
cp ./example-config.toml ./config.toml
|
||||
DOCKER_IP_ADDRESS="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb)"
|
||||
sed -i "s/host = \"localhost\"/host = \"${DOCKER_IP_ADDRESS}\"/" ./config.toml
|
||||
```
|
||||
|
||||
If you used the docker command above, you can use these settings as is, but if you are running mariadb/mysql on another host, port or with another password, adjust the corresponding fields in `config.toml`.
|
||||
This file will contain your database password, but is ignored by git, so it will not be committed to the repository.
|
||||
|
||||
You should now be able to connect to the mariadb instance, after building the program and using arguments to specify the config file.
|
||||
|
||||
```bash
|
||||
@ -42,4 +46,4 @@ To stop and remove the container, run the following command:
|
||||
|
||||
```bash
|
||||
docker stop mariadb
|
||||
```
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user