0

Here is my docker-compose:

version: "2"
services:
  mongodb:
    container_name: "elastic_backend_mongodb"
    restart: "always"
    image: "mongo:latest"
    volumes:
      - "./data/db/:/data/db"
    ports:
      - "27017:27017"
    command: --storageEngine wiredTiger
    networks:
      - "elastic_backend"
  php:
      build: ./develop
      container_name: "elastic_backend_php"
      restart: "always"
      environment:
        PHP_IDE_CONFIG: serverName=elastic_backend
      depends_on:
        - "mongodb"
        - "db"
        - "elasticsearch"
      expose:
        - "9000"
      volumes:
        - "../.:/var/www/html"
      networks:
        - "elastic_backend"
  nginx:
      image: "nginx:latest"
      container_name: "elastic_backend_nginx"
      restart: "always"
      volumes:
        - "./nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro"
        - "./nginx/conf.d:/etc/nginx/conf.d:ro"
      ports:
        - "80:80"
      volumes_from:
        - "php"
      networks:
        - "elastic_backend"
  db:
    container_name: "elastic_backend_mysql"
    restart: "always"
    image: "mysql:5.7"
    command: --max_allowed_packet=32505856
    environment:
      MYSQL_ROOT_PASSWORD: "asd"
      MYSQL_DATABASE: "elastic_backend"
    ports:
      - "3306:3306"
    volumes:
      - "./mysql:/var/lib/mysql"
    networks:
      - "elastic_backend"
  elasticsearch:
    container_name: "elastic_backend_es"
    image: elasticsearch:6.5.4
    environment:
      - discovery.type=single-node
    ports:
      - "9200:9200"
      - "9300:9300"
networks:
  elastic_backend:

So, all works well except php container can't ping elasticsearch container. db and mongodb containers are pinged well from php container. I tried also to use "links" and analogue directives for docker but with no any luck. So what am I doing wrong?

I'm able to GET rest interface of elasticsearch from host (macos):

{
  "name": "cDsdqXL",
  "cluster_name": "docker-cluster",
  "cluster_uuid": "010ETY4zT_C8XJu1IfON-g",
  "version": {
    "number": "6.5.4",
    "build_flavor": "default",
    "build_type": "tar",
    "build_hash": "d2ef93d",
    "build_date": "2018-12-17T21:17:40.758843Z",
    "build_snapshot": false,
    "lucene_version": "7.5.0",
    "minimum_wire_compatibility_version": "5.6.0",
    "minimum_index_compatibility_version": "5.0.0"
  },
  "tagline": "You Know, for Search"
}

1 Answer 1

2

PHP container can't access elasticsearch container here because, elasticsearch service is not connected to elastic_backend network. Add this under elasticsearch service.

    networks:
      - "elastic_backend"
Sign up to request clarification or add additional context in comments.

1 Comment

Ahhhh really, thank you very much! New fresh look at issue is priceless!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.