mf/docker-ip

从 `ifconfig` 中找到合适的 IP,然后将该 IP 分配到主机和 Docker 文件中,并允许撤销更改。

1.0.0 2017-06-10 19:36 UTC

This package is auto-updated.

Last update: 2024-08-29 01:19:22 UTC


README

Latest Stable Version Total Downloads Build Status Coverage Status License

ifconfig 中找到合适的 IP,然后将该 IP 分配到主机和 Docker 文件中,并允许撤销更改。

如何使用?

作为依赖项安装

composer require --dev mf/docker-ip

如何运行它?

显示可用命令列表

vendor/bin/docker-ip-console list

用法

vendor/bin/docker-ip-console [command] [arguments]

可用命令

  help                          Displays help for a command
  list                          Lists commands
 docker-ip
  docker-ip:distributeIpToHost  Finds suitable IP from `ifconfig` and then distribute this IP into hosts and docker file
  docker-ip:revert              Reverts changes from `distributeIpToHost` in hosts and docker file

将 IP 分配到主机

ifconfig 中找到合适的 IP,然后将该 IP 分配到主机和 Docker 文件中。

用法

vendor/bin/docker-ip-console docker-ip:distributeIpToHost [options]

选项

   -d, --domain=DOMAIN              Your local domain
       --docker-file=DOCKER-FILE    Full path to your docker compose yml
       --hosts[=HOSTS]              Full path to your hosts file [default: "/etc/hosts"]
   -p, --placeholder[=PLACEHOLDER]  Placeholder used in DOCKER_FILE [default: "DOCKER_IP_PLACEHOLDER"]
   -h, --help                       Display this help message
   -q, --quiet                      Do not output any message
   -V, --version                    Display this application version
       --ansi                       Force ANSI output
       --no-ansi                    Disable ANSI output
   -n, --no-interaction             Do not ask any interactive question
   -v|vv|vvv, --verbose             Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

/etc/hosts 的示例

127.0.0.1 your_domain

DOCKER_FILE.yml 的示例

extra_hosts:
  - "your_domain:DOCKER_IP_PLACEHOLDER"

撤销更改

撤销主机和 Docker 文件中 distributeIpToHost 的更改。

用法

vendor/bin/docker-ip-console docker-ip:revert [options]

选项

       --docker-file=DOCKER-FILE  Full path to your docker compose yml
       --hosts[=HOSTS]            Full path to your hosts file [default: "/etc/hosts"]
   -h, --help                     Display this help message
   -q, --quiet                    Do not output any message
   -V, --version                  Display this application version
       --ansi                     Force ANSI output
       --no-ansi                  Disable ANSI output
   -n, --no-interaction           Do not ask any interactive question
   -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

/etc/hosts 的示例

#REPLACED_BY_DOCKER_IP 127.0.0.1 your_domain
{DOCKER_IP} your_domain

DOCKER_FILE.yml 的示例

extra_hosts:
#REPLACED_BY_DOCKER_IP       - "your_domain:DOCKER_IP_PLACEHOLDER"
  - "your_domain:{DOCKER_IP}"