Test if Docker Container Has Exposed Port (ex: 3306 for mariadb/mysql)

How Test to see if docker container has exposed port (in this case mariadb/mysql has 3306 exposed)

Be careful when running docker containers, even if you have firewall installed for example csf.

If you expose port in docker compose like this:
or in wanted to use container like this:
docker run -p 3306:3306 blabla/blabla-mariadb/mysql
you open your site to a vulnerability.

If you want to test if you have exposed port on your server then, install on localhost TELNET. This is done like this:
sudo apt-get install telnet (if you are on debian/ubuntu)
sudo yum install telnet (Redhat/Centos)
Some default ports so you know what you’re looking for:
-MySQL/Mariadb 3306,
-PostgreSQL 5432,
-MongoDB 27017,
-Microsoft SQL Server 1433,
-Firebird & Interbase 3050

To test connection run:
telnet ip port
example: telent 3306

If connection is successful you should see something like this:

connect to db successful
connect to db successful

If connection is unsuccesful you’ll see something like:

unsuccessful connection to db
unsuccessful connection to db

Fix for exposed port: Fix exposed port in docker container

Last modified: August 28, 2017