Find the IP Address of a running Docker container

Problem

You would like to know the IP Address of a running Docker container.

Solution

Use the following to find out the IP Address by replacing the container_name with the actual container name:

Find the table sizes in MySQL database

Problem

You would like to have a list with all the tables in an MySQL database, sorted with their sizes (actual table and indices).

Solution

You could run the following query to give you a list of all the tables sorted by size:

Take from the answer here

Exporting SQL structure commands from MySQL Workbench

Problem

You would like to export the structure of some specific MySQL tables using MySQL Workbench (ie to create same tables in another database).

Solution

Go to the table name, right click, select ‘Copy To Clipboard’, then ‘Create Statement’ and finally go to a new file or editor and paste the command from the clipboard.
Just have in mind that you may need to delete the AUTO_INCREMENT from the SQL.
Solution was described here

Copying files between two folders without overwriting existing ones in destination folder.

Problem

You would like to copy the contents of a source directory to a destination directory without overwriting existing files on the destination.

Solution

You can use

and you can also use the –dry-run option to test before running it.

Connection refused when using http monitoring with blackbox_exporter and prometheus

Problem

You are trying to set up http endpoint monitoring with prometheus and blackbox_exporter by specifying something like the following:

but you are getting the error (in prometheus targets) that connection was refused.

Solution

First specify the ip protocol as ip4 if you are not using ip6 like:

And then make sure that you use the container IP address in the replacement field if you have started blackbox_exporter as a docker container (tip taken from here), which you can find by looking for the container IP address (docker inspect blackbox_exporter | grep IPAddress).

So your prometheus configuration should look like the following (different replacement IP):

Using a primary key not named id with Ecto and Mysql

Problem

You would like to use a legacy or a database you don’t have control over, with Phoenix, but the primary key of the table it is not named ‘id’.

Solution

You can define the primary key using the @primary_key as in:

Taken from here