This is the article on the 15th day of the 2020 XTech Group Advent Calendar. I'm Nishimaki, a new graduate of Excite Japan Co., Ltd.
This time, I would like to introduce how to easily build an environment for MySQL and Redis with Docker and Alfred. What you need You can start it with Docker and call it from anywhere with Alfred. The code is here.
macOS: 10.15.1 docker-compose: 1.27.4 Alfred: 4.0.9
Launch the following with docker-compose.
Use adminer for the MySQL GUI client and redis-insight for the Redis GUI client. The reason is that the web app was better than the desktop app (I personally want to complete it on the web as much as possible) and it is lightweight. By the way, I used to use Sequel Pro and Medis, but neither is very easy to use, and I personally prefer adminer and redisinsight.
$ docker-compose up -d
version: '3'
services:
redis:
image: redis:latest
restart: always
ports:
- 6378:6379
command: redis-server /usr/local/etc/redis/redis.conf
volumes:
- ./redis/data:/data
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
redisinsight:
image: redislabs/redisinsight
restart: always
ports:
- 8011:8001
volumes:
- ./redisinsight:/db
depends_on:
- redis
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_USER: docker
MYSQL_PASSWORD: docker
MYSQL_ROOT_PASSWORD: local_root_password
MYSQL_DATABASE: db
ports:
- 3307:3306
volumes:
- ./mysql/data:/var/lib/mysql
- ./mysql/conf.d:/etc/mysql/conf.d
adminer:
image: adminer:latest
restart: always
environment:
# choose your favorite design from https://www.adminer.org/
ADMINER_DESIGN: lucas-sandery
ports:
- 8090:8080
depends_on:
- mysql
Once launched, open a GUI client and try connecting to MySQL and Redis.
When you open adminer, it looks like this. The design can be changed with environment variables.
For the connection information server, enter the service name mysql written in docker-compose.yml
.
redisinsight looks like this. The connection information is as follows.
docker-compose.yml
Use Alfred. What is Alfred? For those who say, To you who are not good at using Alfred![Complete version of how to use Alfred] It's kind of like an upward compatibility for spotlight search. If you register http: // localhost: 8090/in Alfred's Web Search, you don't need to remember the port number and you can call it from anywhere, which is convenient. Web Search means that if you register a URL with a keyword, you can open the registered URL in your browser by executing the keyword in Alfred. Try to register http: // localhost: 8090/as shown in the image.
After registration, when you execute it, the registered URL will open automatically.
Recently, the number of tools that can be installed with Docker is increasing, so I thought that if you use it well, it seems that the onboarding cost will be reduced. Please try it out ~
Recommended Posts