Closed Kabingeran closed 4 years ago
hmm the mysql (or mariadb here) inside the docker is not meant to be used from host context. but the dockerized app itself can access database at 127.0.0.1:3306 as said in docs.
if you still want db access from host context you can expose the port in docker-compose.yaml:
# ./docker-compose.yml
version: '3'
services:
app:
image: adhocore/lemp:7.4
container_name: some-app
volumes:
- db_data:/var/lib/mysql
ports:
- 8080:80
- 13306:3306 # <------ this
environment:
MYSQL_ROOT_PASSWORD: supersecurepwd
MYSQL_DATABASE: appdb
MYSQL_USER: dbusr
MYSQL_PASSWORD: securepwd
volumes:
db_data: {}
then access db at 127.0.0.1:13306
from host context.
It did not help I just connect to MySQL from the IDE. It would also be great to configure ssh
IDE is in host so port expose and usage with 127.0.0.1:13306 is the way to go.
another way could be terminal access:
docker exec -it yourcontainername mysql -uyouruser -p
After restarting OS - it worked!
ok then closing
Continuing, I would like to ask you to specify other ports by analogy.
Hi! I get errors like: [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up. [HY000][1130] null, message from server: "Host '172.18.0.1' is not allowed to connect to this MariaDB server". [Warning] Aborted connection 10 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.1' (This connection closed normally without authentication)
How to configure docker compose file ?