Traefik test drive Docker container discovery

Simple config for testing Traefik with Docker:

# traefik.toml
debug = true

entryPoint = 'traefik'
debug = true

endpoint = 'unix:///var/run/docker.sock'
domain = 'docker.localhost'
watch = true

Run Traefik in a docker container:

docker run --rm -l traefik -p 8080:8080 -p 80:80 \
    -v $PWD/traefik.toml:/etc/traefik/traefik.toml \
    -v /var/run/docker.sock:/var/run/docker.sock traefik

Fire up one docker compose setup and visit http://localhost:8080

Log mysql queries in Docker container

To log mariadb (mysql) SQL queries in a Docker container add - ./docker/mysql/conf.d:/etc/mysql/conf.d to volumes of the database service.

version: '3'

     container_name: db
     image: mariadb:10.1
       - db_data:/var/lib/mysql
       - ./docker/mysql/conf.d:/etc/mysql/conf.d


The contents of docker/mysql/conf.d/my.cnf

# docker/mysql/conf.d/my.cnf

general_log = 1
general_log_file = /var/log/mysql/query.log

slow_query_log = 1
long_query_time = 1 # seconds
slow_query_log_file = /var/log/mysql/slow.log
log_queries_not_using_indexes = 0


Docker Cannot create container for service db: devmapper: Error mounting

Just wanted to start working and got the following error from Docker:

Cannot create container for service db: devmapper: Error mounting ...

Gladly I remembered that I updated the Linux kernel in the morning so after computer restart I had no issue 🙂

Thanks Arch Linux for the kick to learn Docker

Thanks to Arch Linux and its rolling release strategy it comes with PHP 7.1 as default. After some months of having the following in /etc/pacman.conf

IgnorePkg = php php-apache php-gd php-intl php-mcrypt php-pgsql php-geoip php-cgi php-embed php-enchant php-fpm php-imap php-odbc php-phpdbg php-pspell php-snmp php-sqlite php-tidy php-xsl

I pushed myself to learn more and finally start creating some Dockerfiles for some legacy PHP projects.

Docker host vs. local host PHP

Connect to localhost MySQL from Docker container

To test connection to MySQL/MariaDB server running on localhost from Docker container try:

docker run --rm -it --net=host mariadb mysql -u root -h
--rm  Automatically remove the container when it exits
-i    Keep STDIN open even if not attached
-t    Allocate a pseudo-TTY
--net Connect a container to a network