Docker compose:

For example, here is my project structure:

project
     |
     +-- docker-compose.yml
     |    
     +-- hq-backend
     |  +-- Dockerfile
     |  +-- .env.docker-compose

here is my docker compose file:

  • Invalid ELF header xgboost (using a pkl in a Docker container)
  • Elastic Beanstalk Multi-Container Environment cannot mount fuse mount as docker volume
  • Updating docker registry in ubuntu 14.0
  • How can my friend and I share an exact development environment together while on different operating systems?
  • Shutting down MongoDB inside Docker container causes 100% CPU
  • Docker run with “-v” create another shared directory
  • db:
      container_name: hq-db
      image: postgres:latest
      ports:
        - "5432:5432"
      environment:
        POSTGRES_USER: user_name
        POSTGRES_PASSWORD: password
        POSTGRES_DB: db_name
    
    mongo:
      container_name: hq-mongo
      image: mongo:3.2.9
      tty: true
      stdin_open: true
      ports:
        - "27027:27027"
      volumes:
        - mongo:/data/db
    
    hq-backend:
      env_file:
        - ../hq-backend/.env.docker_compose
      build: ../hq-backend/
      dockerfile: Dockerfile
      ports:
        - "8686:8686"
      volumes:
        - ".:/webapp"
      links:
        - db
        - mongo
    

    When I tried to run docker-compose up. I always meet this exception at the end:

    ERROR: for hq-backend Cannot start service hq-backend: Cannot link to
    a non running container: /hq-mongo AS /project_hq-backend_1/mongo

    Here is my environment file:

    ENV=dev
    DB_HOST=db
    DB_ADDRESS=db
    DB_PORT=5432
    POSTGRES_DB=db_name
    POSTGRES_USER=username
    POSTGRES_PASSWORD=password
    
    DB_MONGO_ADDRESS=mongo
    DB_MONGO_PORT=27027
    

    This problem is only with mongo service, not db service. After that, if I tried to run docker-compose up again, no error found, but my hq-backend will throw exception because cannot connect to mongo db. In other word, I just meet this problem when rebuild hq-backend from scratch.

    Please tell me about this problem.

  • mysqldump does not dump everything when running in script
  • build docker image with dockerfile by jenkins
  • Windows Container on Windows 10 Insider Build and Docker for Windows
  • Docker: Staging multiple containers for one application
  • How do you remove the contents of a docker volume?
  • How to update docker version in AWS ECS
  • 2 Solutions collect form web for “Docker compose:”

    Remove tty and stdin_open options from docker-compose file.
    i suppose that it’s messing with how docker-compose is handling containers.
    if You want to execute commands inside mongo container then after compose up just login into it using:
    docker exec -t -i hq-mongo /bin/bash

    By the way – You may consider to use docker-compose version 2 or 3 and depends_on instead of links
    https://docs.docker.com/compose/compose-file/compose-file-v2/

    Try adding depends_on to hq-backend at the same level as links. For example:

    depends_on:
      - mongo
      - db
    links:
      - db
      - mongo
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.