Skip to content

Docker Local Services

Alexander Lukyanov edited this page Mar 15, 2023 · 15 revisions

Docker Local Services is a stack of containers that shared between all environments. It contains:

  • Traefik - As reverse proxy and request router between containers
  • Portainer - Container management system
  • MailHog - An Email catcher. Emails from all containers will be delivered to the MailHog
  • MariaDB - The database instance, it is shared between containers what let you use several containers at the same time.
  • Adminer - A database management tool.
  • SSH Agent - A ssh-agent that let you use your ssh keys in the CLI container

Before You Get Started

  1. Install docker and docker-compose

NOTE: On Linux you may need to add sudo before docker commands.

Get Started

For the basic usage you don't need to modify any of this configurations

  1. Copy folder Local_Services to your local machine
  2. Navigate into the directory Local_Services
  3. Execute docker-compose up -d to start containers.
  4. Add entries to your local hosts file:
127.0.0.1 traefik.local.test
127.0.0.1 portainer.local.test
127.0.0.1 mailhog.local.test
127.0.0.1 adminer.local.test

NOTE: The hosts file location may be unique to a OS. The common hosts file path is C:\Windows\System32\drivers\etc for Windows or /etc/hosts for Linux

  1. Verify in browser each of the Urls above.

NOTE: At the first time when you will try to open any of urls there might be a message about invalid SSL certificate. The environment uses self-signed SSL certificate that's the reason of this message.

Access

Service Host Username/Password
Traefik https://traefik.local.test/ N/A
Portainer https://portainer.local.test/ admin/admin
Mailhog https://mailhog.local.test/ N/A
Database 127.0.0.1:3306 root/pass OR magento2/magento2
Adminer https://adminer.local.test/ root/pass OR magento2/magento2

NOTE: The Portainer may give an option to select which environment you want to use. In this case select "Docker"

image

Advanced Usage

Update Container's Images

When you want to update container's images run the following commands from the Local_Services directory:

docker-compose stop
docker-compose pull
docker-compose up -d 

MariaDB

Customization f my.conf

You will notice a directory mysql with a single file custom-config.cnf. You can add adjustments to the MariaDB default configuration to this file. After you revised the file you need to restart containers to apply changes. From the Local_Services directory run following commands:

docker-compose stop
docker-compose up -d 

Database Dump

An example of the database dump command for database named magento:

docker-compose exec db sh -c 'exec mysqldump -umagento -pmagento magento' >  {path}/dump.sql

NOTE: You may need to change the username and password for a database. The example uses credentials from the Access Section

SSH-Agent: Add a SSH key

You can add your local ssh key with the command (from the local services directory):

docker-compose exec ssh-agent  ssh-add /root/.ssh/id_rsa

Then verify that the key has been added with the command:

docker-compose exec ssh-agent ssh-add -l
Clone this wiki locally