Docker Community Forums

Share and learn in the Docker community.

Moving docker-compose.yml file to a different dir

(Yossibaruch) #1


Issue type: General
OS Version/build: Linux ubuntu 16.04
Steps to reproduce: create some containers with your own user and from your homedir using docker-compose, move the docker-compose.yml file to another dir and try to docker-compose down–>up the containers

I’ve used docker-compose on a test environment, had my fun with it and got some containers up and running (wordpress, nginx, mariadb, trac). I’ve installed docker and docker-compose and used it to deply the containers from my own homedir and user.

Now I want to start working correctly and not lose any data, that means I need to migrate the docker-compose.yml file to a different location (say, /opt/docker) and the owner of the file should be “docker” user.

How do I do that without losing data and configurations? I can live with some downtime on the containers but I have worked on them for quite some time (me and my team)

(Svagml) #2

Nobody has answered this question? I am facing this issue currently. I want to move a docker-compose.yml file to another directory. Since I still don’t really know best practices on where your compose files should actually go, I started with /etc/docker/compose-files//docker-compose.yml. I wanted to move this to another directory that is actually a soft link to a NAS so my configs can survive a failure. In addition, I wanted to eventually combine some compose files that are related and have them in their own service section within same yml file.

(Joffrey F) #3

Just make sure you’re using the same project name before and after the move (either with the -p command-line option or the COMPOSE_PROJECT_NAME variable).