0

I created a docker container with docker-compose in my VPS and I want to access it from my local computer but the connection will refuse. also, I allowed the 3306 port in the VPS.

my docker-compose.yml file:

version: "3"

services:
  mariadb:
    image: mariadb
    container_name: mariadb
    restart: 'always'
    volumes: 
      - ./conf:/etc/mysql
    environment:
      MYSQL_ROOT_PASSWORD: ${password}
      MYSQL_DATABASE: ${database}
      MYSQL_USER:  ${username}
      MYSQL_PASSWORD: ${password}
    ports:
      - 3306:3306

how may I access the MariaDB server from my local computer?

1

Check netstat -tlpn on the VPS, can you see 0.0.0.0:3306 or something like that? If so, check the firewall. Both the firewall in the operating system and the firewall from the VPS provider (if there is any). As a last resort (and not a bad idea) - you can connect to your VPS via VPN - there are good openvpn tutorials on the internet. The reason why the VPN is a good idea - especially for a development server is that you may need to allow the user from everywhere (if you do not have a static IP address) and if you accidentally create some 'testuser' with 'testpassword' anybody from the internet will be able to connect to your db. So use good passwords, limit access to your public IP and use VPN if possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.