Search code examples
dockermariadbvirtual-machinewindows-7-x64docker-machine

Getting access to database in the docker container on VM


I work on PC under Windows 7 x64.

I installed the OracleVM, then installed there Ubuntu 18.04. In Ubuntu, I installed Docker and created and run an environment with PHP, Nginx, and MariaDB and I managed to set up a Drupal 8 site there. All works successfully, and I managed to get access to the site from a browser on my Windows PC. I set it up using mapping the ports on VM settings.

But I don't know how to get access to my database in that container from a windows client, for example, from HeidiSQL. Mapping the ports doesn't help me, unfortunately.

Here are the list of my containers

example3_project_adminer     /entrypoint.sh php -S 0.0. ...   Up      9000/tcp            
example3_project_mailhog     MailHog                          Up      1025/tcp, 8025/tcp  
example3_project_mariadb     /docker-entrypoint.sh mysqld     Up      3306/tcp            
example3_project_nginx       /docker-entrypoint.sh sudo ...   Up      80/tcp              
example3_project_php         /docker-entrypoint.sh sudo ...   Up      9000/tcp            
example3_project_portainer   /portainer --no-auth -H un ...   Up      9000/tcp            
example3_project_traefik     /traefik -c /dev/null --we ...   Up      0.0.0.0:8000->80/tcp

Could you clarify me, how to do it?


Solution

  • I managed to do it. First, I added ports forwarding in the configuration of my mariadb container.

    the mariadb configuration

    I executed the following docker commands

    docker-compose stop
    docker-compose up -d
    

    later, I added a new rule in the VM port forwarding rules

    VM port forwarding rules

    Now I'm able to connect to the database from my windows client program