node.jsmongodbdockerdocker-composeokteto

Okteto error building image "failed to solve: content digest sha256: not found


currently, I am trying to create an Okteto development environment with a NodeJS project + Mongo database. I already created an Okteto account and authenticated Okteto with my CLI.

I am using Okteto CLI version 2.3.3 and would like to use the Docker compose file configured for my application. My docker-compose.yml file is as following:

version: '3'

services: 
  app:
    container_name: docker-node-mongo
    restart: always
    build: .
    ports:
      - 3000:3000
    environment:
      DB_HOST: mongo
      DB_PORT: 27017
      DB_USER: kevin
      DB_PASS: Ab12345!
      DB_NAME: devops_week1
    volumes:
     - .:/user/src/app

  mongo:
    container_name: mongo
    image: mongo
    restart: always
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: kevin
      MONGO_INITDB_ROOT_PASSWORD: Ab12345!
    volumes:
      - ./mongo-data:/data/db

Steps I took to create Okteto development environment (inside local repo folder):

  1. okteto context use https://cloud.okteto.com
  2. okteto up

Unfortunately, I get the following error during okteto up command:

 i  Building the image 'okteto.dev/devops-2223-kevinnl1999-mongo:okteto-with-volume-mounts' in tcp://buildkit.cloud.okteto.net:443...
[+] Building 2.9s (7/7) FINISHED
 => [internal] load .dockerignore                                                                                                                                                                                                   0.5s 
 => => transferring context: 67B                                                                                                                                                                                                    0.4s 
 => [internal] load build definition from buildkit-3009021795                                                                                                                                                                       0.6s 
 => => transferring dockerfile: 82B                                                                                                                                                                                                 0.4s 
 => [internal] load metadata for docker.io/library/mongo:latest                                                                                                                                                                     0.9s 
 => [internal] load build context                                                                                                                                                                                                   0.4s 
 => => transferring context: 32B                                                                                                                                                                                                    0.3s 
 => => resolve docker.io/library/mongo@sha256:2374c2525c598566cc4e62145ba65aecfe1bd3bf090cccce1ca44f3e2b60f861                                                                                                                      0.1s 
 => CACHED [2/2] COPY mongo-data /data/db                                                                                                                                                                                           0.0s 
 => ERROR exporting to image                                                                                                                                                                                                        0.7s 
 => => exporting layers                                                                                                                                                                                                             0.0s 
 => => exporting manifest sha256:1aa8d8d6b1baf52e15dbb33e3578e5b2b4d827b20f279f4eb7577b7ee1404c60                                                                                                                                   0.1s 
 => => exporting config sha256:21be98f915c4523d85e7d89832742648b9fd2ea33d240ba6cd8c6b94d111c406                                                                                                                                     0.0s 
 => => pushing layers                                                                                                                                                                                                               0.6s 
------
 > exporting to image:
------
 x  Error building image 'registry.cloud.okteto.net/kevinnl1999/devops-2223-kevinnl1999-mongo:okteto-with-volume-mounts': build failed: failed to solve: content digest sha256:10ac4908093d4325f2c94b2c9a571fa1071a17a72dd9c21c1ffb2c86f68ca028: not found

It looks like Okteto is looking for an old volume. I already tried the steps above in a new Okteto namespace and tried the okteto up --reset command hoping that it would clear some cache. What could be the solution to this error?


Solution

  • I figured out a solution to my problem. The problem was about cache as I suspected. What I did to solve the problem:

    1. Removed old container, image and volumes
    2. docker builder prune --all
    3. docker build with --no-cache flag

    After that, okteto up was succesful.