docker run -d consul -P
-P
应该将Dockerfile中的所有 EXPOSED 端口映射到主机。在没有工作的情况下运行命令就-P
可以了,docker ps
显示如下:
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
使用-P
容器时立即退出。当我跑
docker logs bc23fb8b61a6
我收到此错误:
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:
[…]
我还尝试/var/log
从容器映射到本地目录,不幸的是它仍然是空的。
任何想法出了什么问题以及如何访问容器的日志?