Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose does not see volumes changes in docker-compose.yml

I'm working with docker-compose.

My docker-compose.yml looks like

redis:
  image: redis
  expose:
      - "6379"
  volumes:
      - ./redis:/data

nerdzcrush:
  image: nerdzeu/docker-nerdzcrush
  ports:
      - "8181:81"
  links:
      - redis
  volumes:
      - ./mediacrush:/home/mediacrush

When I run docker-compose up everything works fine.

After that, I needed to change the mount path. I stopped the containers with docker-compose stop, I changed my docker-compose.yml in this way:

redis:
  image: redis
  expose:
      - "6379"
  volumes:
      - ./nerdzcrush/redis:/data

nerdzcrush:
  image: nerdzeu/docker-nerdzcrush
  ports:
      - "8181:81"
  links:
      - redis
  volumes:
      - ./nerdzcrush/mediacrush:/home/mediacrush

And I removed the old directories with

sudo rm -rf ./mediacrush ./redis

After that, I started the containers wiht docker-compose up -d

I expect that the containers start to work with the new path, but I see that the old path are used. Thus I have again ./mediacrush and ./redis in my folder.

That's something I understood wrongly about docker-compose or that's an issue with docker-compose?

I'm using docker-compose version: 1.5.0dev

Thank you

like image 584
nessuno Avatar asked Oct 19 '22 23:10

nessuno


1 Answers

It's only supposed to preserve volumes if they are container data volumes (not host volumes like in your case).

I would try running docker-compose rm to remove the containers (after stopping them). After that the up should use the correct path.

like image 101
dnephin Avatar answered Oct 30 '22 19:10

dnephin