Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Volume driver reports as "changed" on second "libcompose up" attempt #509

Open
wagoodman opened this issue Sep 9, 2018 · 3 comments
Open
Labels

Comments

@wagoodman
Copy link

wagoodman commented Sep 9, 2018

Currently when attempting to run bring services up with libcompose, on the second attempt the Up command fails with Volume "node_modules" needs to be recreated - driver has changed.

The example docker compose file:

version: '2'

services:

  react:
    image: node:8
    networks:
      react-lan:
    command: yarn start
    working_dir: /app
    ports:
      - "3000:3000"
      - "4444:4444"
      - "9222:9222"
    volumes:
      - .:/app
      - yarn_cache:/home/node/.cache
      - node_modules:/app/node_modules

volumes:
  node_modules:
  yarn_cache:

networks:
  react-lan:

The issue looks to be here:

if volumeResource.Driver != v.driver {
return fmt.Errorf("Volume %q needs to be recreated - driver has changed", v.name)
}

It is assumed that there will be a known configured value for config.VolumeConfig.Driver, however, if no configuration is passed to this function, then no default value is provided (it remains an empty string):

if config != nil {
vol.driver = config.Driver
vol.driverOptions = config.DriverOpts
vol.external = config.External.External
}

Changing the volumes section does indeed fix the issue...

...
volumes:
  node_modules:
    driver: local
  yarn_cache:
    driver: local
...

...however, this is not desirable. Since it is very common to not require the volume driver to be specified directly in the docker-compose.yaml then it makes sense to only check for a change in driver only when comparing against a non-empty value.

Another solution to this would be to add a default to the config.VolumeConfig.Driver to the value of
local somewhere here:

func (p *Project) handleVolumeConfig() {

@xZero707
Copy link

xZero707 commented Mar 29, 2020

I just encountered this with version 1.25.4 (From pip).
Any progress with this? It's an old issue that remains unsolved.


If you have encountered it, the workaround is available in reference posted by @frafra, just above this comment.

@thaJeztah
Copy link
Member

@xZero707 this is the repository for libcompose, a go-implementation of a library for handling compose-files; I think you might be looking for the docker compose issue tracker; https://github.com/docker/compose/issues

@xZero707
Copy link

xZero707 commented Apr 30, 2020

@thaJeztah I'm sure it's libcompose as I encountered error inside portainer/portainer container which utilized libcompose for stack deployment.

I agree, however that docker-compose from pip has nothing to do with libcompose. Sorry about the confusion I've created.
docker-compose on the host is not even used in a containers.


Also, to clarify; This bug is not in Portainer but in libcompose library as discussed here:
portainer/portainer#1989
timoknapp/rpi-nas#1

Anyway, libcompose is deprecated, so I suppose this discussion is pointless.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants