Configure your MySQL/Mariadb server to accept local connections

So lets say that you have created a Database server, and you wanted to accept only connections from other servers using the internal/private IP, to be honest I found that the easy way is to do that via iptables, am not going to talk about how to save your iptables as I will assume that you know how to do so, if you dont search using google.com

Lets assume that your private ip is 10.2.10.2 and your public ip is 192.168.2.10 so now you will have to execute the following commands :

Continue reading

Filed under: Linux, MySQL

Run your docker images in order

One of the many things that I found annoying in Docker (when you use docker-compose) is that you have no control over the order which the images is going to be up and running, in the documentation they have pointed out to three ways, am not going to cover them all, am just going to cover my experience with dockerize and how I used it to make sure that the database is up and running before I run the next image.

PS: please note that my way is not the best way, but it worked for me, and you should invest more time knowing and familiarize yourself with dockerize.

  1. Make sure that you install dockerize within the image which should be waiting for other images to finish
  2. Make sure that your image does not have any service that run as daemon ( In my case it was NGINX )
  3. Make sure that your entrypoint should look like :
  4. You will need to replace  tcp://database:5432 with the service and the port that you are waiting for, lets say for example tcp://nginx where we need to make sure that nginx is up and running on the default port 80.
  5. You will need to replace kong start with the service that you want to run, in my case it was Kong server

You can look at this github repo where I created a small docker repo to run Kong and Postgresql out of the box

Filed under: docker, Linux, Nginx, Other

Run node apps on port 80 without Root permissions

Most of us run the node apps under the root user, so last time I talked about using IPTables to do some tricks which will route the requests from port 80 to port 8080.

Today I was able to do so without IPTables , and you can run this command with SUDO to give node the ability to use the port 80 :

I used it on Ubuntu 16.04 and it worked like a charm.

PS: I noticed that the command was not clear so I need to put it in an image

screen-shot-2016-11-09-at-10-58-39-am

Filed under: Code, Linux

How to bind Docker image to specific IP on MAC

PS: this is an experimental idea so it might not work for you.

I’ll try to make short here, so basically you will have to pass the IP with the expose port while you execute docker run for example something like

Now the question why do I need to do something like that since at the end docker will be bind to localhost and more specific to 0.0.0.0 , and to be honest this is just a simple try for me to imitate the ability to have two (or more) vagrant boxes running on the same machine and both has the port 80 exposed to the host.

So normally you will only have one image cause you cant have two images on the same port (or at least this is what I have in my mind right now), so the command above will help, now when you try it you will face a small problem, which is that the IP should be the same as your host IP and you cant have both images have the same IP, so it wont work and we have gain nothing, lets talk about how vagrant/virtualbox work, they do a small trick where virtualbox will create a virtual network adapter and configure it to have the IP which you specified in Vagrantfile, so I guess we will have to do the same Creating a new virtual network adapter.

Continue reading

Filed under: Code, docker, Linux, Nginx, PHP