Download the PHP package webproject-xyz/docker-hostsfile-sync without Composer

On this page you can find all versions of the php package webproject-xyz/docker-hostsfile-sync. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package docker-hostsfile-sync

Docker Hosts File Sync

CI Release Docker Image PHP Version Latest Stable Version Total Downloads License

Automatically sync your /etc/hosts file with running Docker containers. Each container gets hostnames for every network it's connected to.

Inspired by docker-hostmanager

Features

Quick Start

Using Docker (Recommended)

Using Docker Compose

Configuration

Command Line Options

Option Short Description Default
--hosts_file -f Path to hosts file ./tmp-hosts
--tld -t TLD suffix for hostnames .docker
--reverse-proxy-host-ip -r IP address of your reverse proxy -

Environment Variables

You can also configure via environment variables:

Variable Description
HOSTS_FILE Path to hosts file
TLD TLD suffix for hostnames

Examples

Example 1: Basic Setup

A simple web application with a database:

Generated hosts entries:

Now you can access your services:


Example 2: Multiple Networks

When containers are connected to multiple networks, each network gets its own hostname:

Generated hosts entries:

This allows:


Example 3: With Reverse Proxy (nginx-proxy)

For production-like setups with a reverse proxy, use the --reverse-proxy-host-ip option. This routes URL-like hostnames (containing dots) to your proxy:

Generated hosts entries:

Now you can:


Example 4: Network Aliases

Network aliases let you give containers additional hostnames. Aliases containing a dot (.) are treated as URLs and routed to the reverse proxy:

Generated hosts entries:

How It Works

The tool manages a section in your hosts file between these markers:

Everything outside these markers is left untouched.

Hostname Generation Rules

Source Example Generated Hostname Target IP
Container name webapp webapp.networkname Container IP
Simple network alias frontend frontend.networkname Container IP
URL-like network alias app.example.com app.example.com Reverse proxy IP
DOMAIN_NAME env var api.local api.local Reverse proxy IP
VIRTUAL_HOST env var www.app.local www.app.local Reverse proxy IP

URL-like aliases (containing a .) are assumed to be real domain names that should route through your reverse proxy. Simple aliases (no .) are combined with the network name.

Running Locally (Development)

Troubleshooting

Hosts file not updating

  1. Check the container has write access to the hosts file:

  2. Check logs for errors:

Container not appearing in hosts file

Containers must be "exposed" (have at least one network with an IP address). Check your container:

License

MIT


All versions of docker-hostsfile-sync with dependencies

PHP Build Version
Package Version
Requires php Version ~8.5.0
ext-filter Version *
jane-php/open-api-runtime Version ^7.14.0
phpstan/phpdoc-parser Version ^2.3.5
symfony/console Version ^8.1.6
symfony/http-client Version ^8.1.6
symfony/property-access Version ^8.1.4
symfony/property-info Version ^8.1.6
symfony/runtime Version ^8.1.0
symfony/serializer Version ^8.1.6
webproject-xyz/docker-api-client Version ^1.5.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webproject-xyz/docker-hostsfile-sync contains the following files

Loading the files please wait ...