Home > Net >  How do i specify a docker compose file for docker compose run?
How do i specify a docker compose file for docker compose run?

Time:09-21

I was expecting to be able to use docker-compose run -f <with this docker compose file> but it gives me a Usage error.

How do I do that?

Here's my output:

ls docker-compose-file.yml 
docker-compose-file.yml
me@host:~/work/my-dir$ docker-compose -f docker-compose-file.yml run                                                                              
Run a one-off command on a service.

For example:

    $ docker-compose run web python manage.py shell

By default, linked services will be started, unless they are already
running. If you do not want to start linked services, use
`docker-compose run --no-deps SERVICE COMMAND [ARGS...]`.

Usage:
    run [options] [-v VOLUME...] [-p PORT...] [-e KEY=VAL...] [-l KEY=VALUE...] [--]
        SERVICE [COMMAND] [ARGS...]

Options:
    -d, --detach          Detached mode: Run container in the background, print
                          new container name.
    --name NAME           Assign a name to the container
    --entrypoint CMD      Override the entrypoint of the image.
    -e KEY=VAL            Set an environment variable (can be used multiple times)
    -l, --label KEY=VAL   Add or override a label (can be used multiple times)
    -u, --user=""         Run as specified username or uid
    --no-deps             Don't start linked services.
    --rm                  Remove container after run. Ignored in detached mode.
    -p, --publish=[]      Publish a container's port(s) to the host
    --service-ports       Run command with the service's ports enabled and mapped
                          to the host.
    --use-aliases         Use the service's network aliases in the network(s) the
                          container connects to.
    -v, --volume=[]       Bind mount a volume (default [])
    -T                    Disable pseudo-tty allocation. By default `docker-compose run`
                          allocates a TTY.
    -w, --workdir=""      Working directory inside the container

CodePudding user response:

There are options for docker compose that go before the command and options for the command that go after the command. The -f option is for docker compose, so that goes before the command

docker-compose -f <with this docker compose file> run
  • Related