Hi,
I have been trying to get access to MariaDB through docker. While I am able to access MariaDB within my AWS Ubuntu instance in AWS Lightsail through the following commands:
mysql -h <ip-address where database is hosted> -p -u username database
However, when I load the page on the website IP address I get the following error:
** ‘172.18.0.3 is not allowed to connect to this MariaDB Server’**.
This is my docker-compose file:
version: '3.7'
services:
app:
restart: always
build: ./app
ports:
- "8501:8501"
env_file:
- .env
command: streamlit run Main.py
networks:
- streamlit_network
mariadb:
image: mariadb:10.5.17
ports:
- "3306:3306"
volumes:
- db_data:/var/lib/mysql
- db_conf:/etc/mysql/conf.d
environment:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "db"
MYSQL_USER: "user"
MYSQL_PASSWORD: "password"
networks:
- streamlit_network
nginx:
restart: always
build: ./nginx
ports:
- "80:80"
depends_on:
- app
- mariadb
networks:
- streamlit_network
volumes:
db_data:
db_conf:
networks:
streamlit_network:
driver: bridge
I tried removing the network part but I get the same error. I cannot use host mode in network as I need the port bindings for the web page to even load per the configuration.
This is the .env file:
host="mariadb"
user="user"
password="password"
database="db"
port="3306"
When I run this command:
for s in
docker-compose ps -q; do echo ip of
docker inspect -f “{{.Name}}” $sis
docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ $s; done
I get that this IP address: 172.18.0.3 corresponds to app here. Any pointers on this ? Thanks in advance.