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?
You need to put the
-P
argument (which belongs todocker run
) before theconsul
command:Otherwise it is interpreted by Consul and you get a syntax error message for the
consul
command.