Category Archives: Docker/Linux

Docker/Linux scripts and howto’s

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: EXPOSE 3306 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: […]



Fix Exposed port in docker container (mariadb/mysql 3306) even with firewall

How to fix exposed port in docker container – in this case mysql/mariadb on standard 3306 port Docker is very complex, the point is that it baypass your firewall, for example I have csf but docker makes a chain of forwarding ports so that containers are able to communicate with each other. The idea is NOT to run container like this: docker run -p 3306:3306 blabla/blabla-mariadb you SHOULD run it like so: docker run -p 127.0.0.1:3306:3306 blabla/blabla-mariadb same goes for .yml file not this: ports: – “3306:3306” but this: ports: – “127.0.0.1:3306:3306” Now to fix our mistakes: IF you have running container you should: 1. docker stop mariadb (or whatever […]