Skip to content

Run with docker compose which do not export mysql, redis(-cluster). #27

Description

@liudonghua123

Description

Hi, I read the doc about running with docker-compose, but I noticed that some service like mysql, redis(-cluster) are exported to the host which I believe is not best practise due to port conflicts and also not required.

So, I tried to update my own version of docker-compose. But the following docker-compose.yml do not working.

It failed with the following errors, maybe redis(-cluster) or mysql problems.

version: '3'
services:
  mysql:
    image: mysql:5.7.34
    # image: mysql
    privileged: true
    restart: always
    container_name: mysql
    hostname: mysql
    command:
      - "--character-set-server=utf8mb4"
      - "--collation-server=utf8mb4_unicode_ci"
    ports:
      - 3306
    environment:
      - MYSQL_ROOT_PASSWORD=123456
      - MYSQL_DATABASE=apinto
    volumes:
      - ./mysql:/var/lib/mysql
    networks:
      - apinto
  apinto-gateway:
    image: eolinker/apinto-gateway
    container_name: apinto-gateway
    privileged: true
    restart: always
    networks:
      - apinto
    ports:
      - 8099:8099
      - 9400:9400
      - 9401:9401
    volumes:
      - ./apinto/data:/var/lib/apinto
      - ./apinto/log:/var/log/apinto
  apinto-dashboard:
    image: eolinker/apinto-dashboard
    container_name: apinto-dashboard
    privileged: true
    restart: always
    networks:
      - apinto
    ports:
      - 18088:8080
    depends_on:
      - mysql
      - cluster-redis
    environment:
      - MYSQL_USER_NAME=root
      - MYSQL_PWD=123456
      - MYSQL_IP=mysql
      - MYSQL_PORT=3306
      - MYSQL_DB=apinto
      - ERROR_DIR=/apinto-dashboard/work/logs
      - ERROR_FILE_NAME=error.log
      - ERROR_LOG_LEVEL=info
      - ERROR_EXPIRE=7d
      - ERROR_PERIOD=day
      - REDIS_ADDR=cluster-redis:7201,cluster-redis:7202,cluster-redis:7203,cluster-redis:7204,cluster-redis:7205,cluster-redis:7206
      - REDIS_PWD=123456
    volumes:
      - ./apinto-dashboard/work:/apinto-dashboard/work
  cluster-redis:
    container_name: cluster-redis
    image: eolinker/cluster-redis:6.2.7
    hostname: cluster-redis
    privileged: true
    restart: always
    networks:
      - apinto
    ports:
      - 7201
      - 7202
      - 7203
      - 7204
      - 7205
      - 7206
    environment:
      - REDIS_PWD=123456
      - PORT=7201
      - HOST=localhost
    volumes: 
      - ./redis-cluster/data:/usr/local/cluster_redis/data
networks:
  apinto:
    driver: bridge
    ipam:
      driver: default
      # config:
      #   - subnet: 172.100.0.0/24
[root@localhost apinto_dashboard]# docker compose up 
[+] Running 4/0
 ✔ Container mysql             Running                                                                                                    0.0s 
 ✔ Container cluster-redis     Running                                                                                                    0.0s 
 ✔ Container apinto-gateway    Created                                                                                                    0.0s 
 ✔ Container apinto-dashboard  Created                                                                                                    0.0s 
Attaching to apinto-dashboard, apinto-gateway, cluster-redis, mysql
apinto-dashboard  | mysql:
apinto-dashboard  |   user_name: root
apinto-dashboard  |   password: 123456
apinto-dashboard  |   ip: mysql
apinto-dashboard  |   port: 3306
apinto-dashboard  |   db: apinto
apinto-dashboard  | redis:
apinto-dashboard  |   user_name: 
apinto-dashboard  |   password: 123456
apinto-dashboard  |   addr: 
apinto-dashboard  |     - cluster-redis:7201
apinto-dashboard  |     - cluster-redis:7202
apinto-dashboard  |     - cluster-redis:7203
apinto-dashboard  |     - cluster-redis:7204
apinto-dashboard  |     - cluster-redis:7205
apinto-dashboard  |     - cluster-redis:7206
apinto-dashboard  | port: 8080
apinto-dashboard  | error_log:
apinto-dashboard  |   dir: /apinto-dashboard/work/logs
apinto-dashboard  |   file_name: error.log
apinto-dashboard  |   log_level: info
apinto-dashboard  |   log_expire: 7d
apinto-dashboard  |   log_period: day
apinto-dashboard  | 
apinto-dashboard  | 2023/12/01 00:27:27 /home/runner/go/pkg/mod/gorm.io/gorm@v1.24.1/callbacks.go:134 Error 1062: Duplicate entry '1' for key 'PRIMARY'
apinto-dashboard  | [1.612ms] [rows:0] INSERT INTO `namespace` (`name`,`create_time`,`id`) VALUES ('default','2023-12-01 00:27:27.179',1)
apinto-dashboard  | [2023-12-01 00:27:27] [ERRO] get module config version:CLUSTERDOWN Hash slot not served
apinto-dashboard  | [2023-12-01 00:27:27] [WARN] lockKey=updateExtender_1701361647 error=CLUSTERDOWN Hash slot not served
apinto-gateway exited with code 0
apinto-gateway exited with code 0
apinto-gateway exited with code 0
apinto-gateway exited with code 0
apinto-gateway exited with code 0
apinto-gateway exited with code 0
apinto-dashboard  | [2023-12-01 00:27:37] [ERRO] get module config version:dial tcp :7201: connect: connection refused
apinto-gateway exited with code 0
apinto-gateway exited with code 0
apinto-dashboard  | [2023-12-01 00:27:47] [ERRO] get module config version:CLUSTERDOWN Hash slot not served
apinto-dashboard  | [2023-12-01 00:27:57] [ERRO] get module config version:CLUSTERDOWN Hash slot not served
apinto-gateway exited with code 0
apinto-dashboard  | [2023-12-01 00:28:00] [WARN] lockKey=updateExtender_1701361680 error=CLUSTERDOWN The cluster is down
apinto-dashboard  | [2023-12-01 00:28:07] [ERRO] get module config version:CLUSTERDOWN The cluster is down
apinto-dashboard  | [2023-12-01 00:28:17] [ERRO] get module config version:dial tcp :7201: connect: connection refused
^CGracefully stopping... (press Ctrl+C again to force)
Aborting on container exit...
[+] Running 4/4
 ✔ Container apinto-dashboard  Stopped                                                                                                   10.3s 
 ✔ Container apinto-gateway    Stopped                                                                                                    0.0s 
 ✔ Container cluster-redis     Stopped                                                                                                   10.7s 
 ✔ Container mysql             Stopped                                                                                                    1.4s 
canceled
[root@localhost apinto_dashboard]#

I do not familar with redis-cluster, could I replace the cluster version to normal redis service and how to do it?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Release

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions