I want to run Consul from the official Docker image using

docker run -d consul -P

-P should map all EXPOSED ports from the Dockerfile to the host. Running the command without -P works just fine, docker ps displays this:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                  NAMES
bc23fb8b61a6        consul              "docker-entrypoint.sh"   3 seconds ago       Up 1 seconds        8300-8302/tcp, 8400/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp   jovial_booth

When using -P the container exits immediately. When I run

docker logs bc23fb8b61a6

I get this error:

Invalid flags before the subcommand. If these flags are for
the subcommand, please put them after the subcommand.

usage: consul [--version] [--help] <command> [<args>]

Available commands are:

I also tried to map /var/log from the container to a local directory, unfortunately it remains empty.

Any ideas what is going wrong and how I can access the container's logs?

1 Answer 1


You need to put the -P argument (which belongs to docker run) before the consul command:

docker run -d -P consul

Otherwise it is interpreted by Consul and you get a syntax error message for the consul command.

  • 1
    Stupid me, figured that out myself later but forgot to check back here. Thank you anyway for your answer :-).
    – Ulf
    Aug 16, 2016 at 8:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .