Docker-compose mongodb error

Hey guys,

When I try to build a preview environment for my microservices I get this error:
x Error building service 'mongodb': error building image 'registry.cloud.okteto.net/pr-1-iomilovanderpas/flex-app-portal-backend-mongodb:okteto': build failed: failed to solve: content digest sha256:b65bcf19d1445822c0d6f15ea82c9ed82ac1d903cfd6c1284ba7b2409a092845: not found.

This is my docker-compose.yml:

version: '3.8'

services:
  mongodb:    
    image: mongo   
    networks:
    - services-network
    environment: 
        MONGO_INITDB_ROOT_USERNAME: root      
        MONGO_INITDB_ROOT_PASSWORD: root      
        MONGO_INITDB_DATABASE: devops_mongo    
    expose:      
    - 27017    
    restart: always    
    volumes:      
    - ./data:/data/db
  mysqldb:
    image: 'mysql/mysql-server:8.0'
    ports:
    - '3307:3306'
    environment:
        MYSQL_ROOT_PASSWORD: 'root'
        MYSQL_ROOT_HOST: '${DB_HOST}'
        MYSQL_DATABASE: '${DB_NAME}'
        MYSQL_USER: '${DB_USERNAME}'
        MYSQL_PASSWORD: '${DB_PASSWORD}'
        MYSQL_ALLOW_EMPTY_PASSWORD: 1
    volumes: 
    - 'sail-mysql:/var/lib/mysql'
    healthcheck:
        test: ['CMD', "mysqladmin", "ping", "-p${DB_PASSWORD}"]
        retries: 3
        timeout: 5s
    networks:
    - services-network
  rabbitmq:
    image: rabbitmq:management
    container_name: rabbitmq
    hostname: "rabbitmq"
    healthcheck:
      test: rabbitmq-diagnostics -q ping
      interval: 30s
      timeout: 30s
      retries: 3
    networks:
      - services-network
    ports:
      - "15672:15672"
      - "5672:5672"
    environment:
      RABBITMQ_DEFAULT_USER: "admin"
      RABBITMQ_DEFAULT_PASS: "password"

  reservation_service:
    image: flex/reservation-service
    container_name: reservation-service
    hostname: reservation_service
    restart: on-failure
    networks:
      - services-network
    depends_on:
      rabbitmq:
        condition: service_healthy
      mysqldb:
        condition: service_healthy
    ports:
      - "5001:80"
    build:
      context: .
      dockerfile: Reservation.Microservice/Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
  auth_service:
    image: flex/auth-service
    container_name: auth-service
    hostname: auth_service
    restart: on-failure
    networks:
      - services-network
    depends_on:
      rabbitmq:
        condition: service_healthy
    ports:
      - "5002:80"
    build:
      context: .
      dockerfile: Auth.Microservice/Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ENCRYPTION_KEY=${ENCRYPTION_KEY}
      - CLIENT_SECRET=${CLIENT_SECRET}
  api_gateway:
    image: flex/api-gateway
    container_name: api-gateway
    hostname: api_gateway
    restart: on-failure
    networks:
      - services-network
    links: 
      - reservation_service
      - auth_service
    depends_on:
      - reservation_service
      - auth_service
    ports:
      - "5000:80"
    build:
      context: .
      dockerfile: Gateway.API/Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
        
networks:
  services-network:
volumes:
    sail-mysql:
        driver: local

On my local computer the docker-compose.yml builds and runs fine. Do you guys know what I should change in my docker-compose.yml to make it work in okteto? Thank you already.

Hi @iomilovanderpas ! Sorry for the late response. Does the issue still persist?

Hi @AgustinRamiroDiaz, yes the problem has been solved. It was a long time ago, but this is my implementation right now.

mongodb:    
    image: mongo:latest
    networks:
    - services-network
    ports:
      - 27017:27017    
    restart: always    
    volumes:      
    - mongodb_data_container:/data/db
1 Like