abiosoft / colima

Container runtimes on macOS (and Linux) with minimal setup
MIT License
17.73k stars 364 forks source link

Can't cache layers with docker-compose #1026

Open ldanielw1 opened 1 month ago

ldanielw1 commented 1 month ago

Description

On a installation of colima with docker + docker-compose on an m1 mac. It's strange that I can run docker build . and the layers will cache... but then when I run docker-compose build... the layers don't (and they wipe out any layers cached by the previous call to docker build. All of this is done without changing the local files at all.

I also noticed that every time I run docker-compose build, the number of layers is increasing in my colima machine's /var/lib/docker/overlay2. So I'm guessing it just can't find the cached layers and is continuing to create new layers in that folder?

At this point, I honestly can't tell if this is a docker-compose bug or a colima bug... though I never experienced this when I was on Docker Desktop.

here's my docker-compose.yml file:

services:
  db:
    build: { context: ., dockerfile: ./Dockerfile }
    container_name: db
    env_file: [ .env ]
    ports: ["$DB_PORT:$DB_PORT"]
    volumes:
      - $DB_MOUNT:/opt/prod/db/data
      - $DB_CONF_MOUNT:/opt/prod/db/conf/mariadb/server
      - $DB_SECRETS_MOUNT:/opt/prod/db/secrets
      - $DB_SSL_PUBLIC_MOUNT:/opt/prod/db/conf/mariadb/ssl_public
      - $DB_SSL_MOUNT:/opt/prod/db/conf/mariadb/ssl
    networks: [ container-network ]
    user: "${CONTAINER_UID}:myuser"
    logging: { driver: "json-file", options: { max-size: "10m", max-file: "10" } }
    security_opt:
      - no-new-privileges:true
    userns_mode: keep-id:uid=${CONTAINER_UID}

networks:
  container-network:
    name: my-container-network

Version

colima 0.6.8 docker 26.1.1 docker-compose 2.27.0

Operating System

Output of colima status

INFO[0000] colima is running using macOS Virtualization.Framework 
INFO[0000] arch: aarch64                                
INFO[0000] runtime: docker                              
INFO[0000] mountType: sshfs                             
INFO[0001] socket: unix:///Users/dwu/.colima/default/docker.sock