Skip to content

Docker Networking

In the development environment, Pyxis CMS uses a bridge network. Containers communicate with each other using the service names defined in the docker-compose.yml file, avoiding issues with dynamic IP addresses.

Key Services

  • pyxis-admin: Backend (Laravel) - internally accessible on port 8000.
  • pyxis-view: Frontend - internally accessible on port 3000.

This is the most critical concept in a Headless system. The API URL depends on where the request is sent from.

When Astro (or other frontend) generates a page on the server side (inside the container), it must communicate directly with the backend container via the internal network.

  • URL: http://pyxis-admin:8000
  • Why? The frontend container cannot see ports exposed on your machine’s localhost. To the container, localhost refers to itself.

When the user’s browser sends a request (e.g., via JavaScript), it uses the address accessible from your operating system.

  • URL: http://localhost:8000

In the frontend .env files, we separate these two worlds to ensure correct fetching:

Terminal window
# Internal communication URL (SSR)
INTERNAL_API_URL=http://pyxis-admin:8000
# External communication URL (Browser)
PUBLIC_API_URL=http://localhost:8000

⚠️ CAUTION: Attempting to use localhost or 127.0.0.1 inside a container to fetch data from the API will result in a connection error. Always use the service name pyxis-admin.