泊坞窗中的服务无法相互识别

时间:2020-05-31 04:05:17

标签: docker

我正在尝试使Confluence容器与mysql容器通信。它们都是在我的docker-compose.yml

中启动的服务
version: '2'

services:
  db:
    image: mysql:5.7
    networks:
      - confluencenet
    volumes:
            - ./mycustom.cnf:/etc/mysql/conf.d/my.cnf
    restart: always
    command: [mysqld, --character-set-server=utf8, --collation-server=utf8_bin, --default-storage-engine=INNODB, --max_allowed_packet=256M, --innodb_log_file_size=2GB, --transaction-isolation=READ-COMMITTED, --binlog_format=row]
    environment:
      MYSQL_DATABASE: bachelorarbeit_database
      # So you don't have to use root, but you can if you like
      MYSQL_USER: horizon
      # You can use whatever password you like
      MYSQL_PASSWORD: 1P@ssw0rt123
      # Password for root access
      MYSQL_ROOT_PASSWORD: P@ssw0rt
      MYSQL_ROOT_USER: root
    ports:
      # <Port exposed> : < MySQL Port running inside container>
      - '3306:3306'
  confluence:
    image: techgeeks/confluence-mysql-server
    networks:
      - confluencenet
    build:
      context: ./
      args:
        CONFLUENCE_VERSION: 7.4.0
    container_name: confluence
    volumes:
      - confluencedata:/var/atlassian/confluence
    ports:
      - '8090:8090'
      - '8091:8091'
volumes:
  confluencedata:
    external: false
  postgresqldata:
    external: false

networks:
    confluencenet: {}

据我了解,如果两个docker服务必须相互通信,则它们需要共享同一网络。它们分开工作,我可以从外部连接到每个。但是,融合实例无法连接到db服务。

SQLState - 08S01
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

将两者放在同一个docker网络中,我做错了什么?

0 个答案:

没有答案