Running MySQL in a Docker container on MacOS

It’s been a while since I’ve run MySQL server on my MacBook Pro (see past notes here , here and more here) and since I got my new M1 MBP I haven’t installed it yet. Rather than doing a native install, I want to run it as a Docker container so I can throw it away easily when I’m done.

Starting MySQL in a Container

From the MySQL Docker page, run:

docker run -p 3306:3306 --name mysql-springboot -e MYSQL_ROOT_PASSWORD=your-root-pass-here -d mysql

The important part here is -p to expose port 3306 in the container as 3306 on the host. This will allow you to connect to localhost:3306 locally to MySQL in the container as if it’s running locally.

Connecting with mysql shell locally

Connect with mysql shell as if the server is running locally:

mysqlsh -u root

and enter the password when prompted. Create a db and setup a user that you use from your app running locally:

create database example;
create user 'exampleuser' identified by 'examplepassword';
grant all on example.* to 'exampleuser'

AWS Lambda Docker container runtime error: Runtime exited with error: exit status 127

While testing my Lambda using a Docker container, when the Lambda is invoked, I’m getting this runtime error:

Process 17(bootstrap) exited: Runtime exited with error: exit status 127

Process exit status code 127 errors are usually a file not found error. Going back through the Lambda logs, luckily there’s an error telling me I have an error in my shell script:

/var/task/ line 5: output: command not found

Quick and easy fix.