Database backups via mysqldump: from MariaDB container to S3

For a little side project I wanted an easy way to perform regular backups of a MariaDB database and upload the resultant dump gzipped to S3. Here are the steps to make this happen. The setup Docker container running MariaDB Docker engine running on a AWS EC2 instance An S3 bucket as the destination for the dumps Writing the backup script We begin with writing our shell script, backup.sh, which we will later execute in regular intervals from our host: ...

May 13, 2022

Dockerfile Entrypoint: "file not found"

I was working with a fairly simple Dockerfile, defining an entrypoint and always got a “not found” error when trying to run the container. My Dockerfile looked something like this: FROM python:3.9-alpine [...] WORKDIR /app COPY . /app RUN ["chmod", "+x", "./entrypoint.sh"] ENTRYPOINT ['./entrypoint.sh'] Building the image worked without issues, but running the container was giving me the mentioned error: $ docker build -t what/ever:latest [...] $ docker run --rm what/ever:latest /bin/sh: [./entrypoint.sh]: not found I made sure that my entrypoint.sh file actually existed by overriding the entrypoint and inspecting the container: ...

November 9, 2021

Connecting to a host service from within a container using Docker for Mac

TL;DR Use host.docker.internal. When you are running Docker on Linux and want to access services on the host from within a container, you can make use of the docker0 bridge interface (ip a s docker0). This does not work when running Docker for Mac as the interface is inside a separate virtual machine (which you can confirm by getting a shell in that vm: screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty) and thus not visible on the local host. ...

October 11, 2020