Automatic emails using bash and sendgrid

Problem

You would like to be able to automatically send some emails (ie reports) from a linux server, using a bash script that runs in cronjob, without installing an email server on the linux server.

Solution

  • Create an account in Sendgrid and follow the directions for using WebAPI with curl
    here
  • Set up your bash script to use the API key and have a script like the following. If you want to use big or multiple files you will need to use a temporary file for the base64 encoding, as in the example below, as there is a limit in curl.
  • Add your script to crontab
  • Cannot create container for service xxx: invalid mode: /path/to/volume/

    Problem

    You are trying to use docker-compose to get some services up with docker but you see an error like the following:

    Solution

    This is more than likely caused by a typo in your yml file, so go back and check carefully for any typos and correct them.

    ERROR: Couldn’t connect to Docker daemon at http+docker://localunixsocket – is it running?

    Problem

    Using docker-compose up (or build), displays the following error message (even though the same command used to work previously):

    Solution

    This is quite possible caused by permissions issue, as one of the folders files that docker is trying to use is owned by a different user/group from the one trying to use the docker-compose commands. Try to find the file/folder with the different permissions and change it to your user name and group, or use change the files by using something like:

    Adding missing timestamp column in MySQL table

    Problem

    You have a MySQL table that does not have any timestamp information (creating, updating) and you want to add a column that automatically adds a timestamp every time the record is created.

    Solution

    Add the column for timestamp that creates a timestamp every time a new record is created (INSERT) by using the following:

    More information here

    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: