I am relatively new to using docker-compose and am running a stack with the following command
docker-compose \
--project-name version-12 \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-erpnext.yml \
--project-directory installation \
up -d
now, with the non-default docker-compose.yml
files I can't manage to have docker-compose stop
, docker-compose ps
to work. I have tried to use the -f
, or --project-name
flags but couldn't make it happen.
Can anyone kindly advise how to make this work in such a scenario?
You need to repeat all of the docker-compose
options for every command you need to run.
There are two ways around this. One is to write a shell script wrapper that invokes this command:
#!/bin/sh
# I am `docker-compose-erpnext.sh`
# Run me with any normal `docker-compose` options
exec docker-compose \
--project-name version-12 \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-erpnext.yml \
--project-directory installation \
"$@"
Docker Compose also supports environment variables for most of its settings; many of these in turn can also be included in a .env
file . You can't specify --project-directory
this way, but it's documented to default to the directory of the Compose file.
export COMPOSE_PROJECT_NAME=version-12
export COMPOSE_FILE=installation/docker-compose-common.yml:installation/docker-compose-erpnext.yml
docker-compose up -d
docker-compose ps
You can put these two settings in a file name .env
in the directory from which you're running docker-compose
(not the installation
subdirectory); but if you have multiple deployments you're trying to manage, you can't specify an alternate name for the file (there is neither a CLI option nor an environment variable setting for it).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.