You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To bypass the proxy, you can expose ports directly:
64
18
65
-
### Application Networking
19
+
-**Published Ports**: Map container ports to host ports by either adding them into the `Mapped Ports` field in Coolify or defining them in your `docker-compose.y[a]ml` file.
20
+
Example:
66
21
67
-
#### Internal Communication
68
-
Applications within the same destination can communicate:
- **Container Names**: Use container names for internal communication
87
-
- **DNS Resolution**: Docker provides automatic DNS resolution
88
-
- **Port Access**: Use internal ports (not published ports)
89
-
90
-
### External Access
30
+
::: warning CAUTION
31
+
The first number represents the host port while the second number is the container port. Make sure to use unique host ports for each service to avoid conflicts.
32
+
:::
91
33
92
-
#### Through Proxy
93
-
All external traffic goes through the proxy:
94
-
- **Domain Routing**: Proxy routes based on domain/subdomain
- **Default Behavior**: Destinations cannot communicate with each other
110
-
- **Network Separation**: Each destination has its own Docker network
111
-
- **Container Isolation**: Containers in different destinations are isolated
41
+
Resources within the same destination can communicate over the internal Docker network using the **Container Names**, **Network Alias** and **internal Ports** of your Resources.
112
42
113
-
### Inter-Destination Communication
114
-
To enable communication between destinations:
43
+
### Example: Connection String Between Apps
115
44
116
-
#### Option 1: Shared Network
117
-
Create a shared network and connect multiple destinations:
118
-
```bash
119
-
# Create shared network
120
-
docker network create shared-network
45
+
Consider a Next.js and Express API deployed to the same destination. To connect Next.js to the Express API, we follow these steps:
121
46
122
-
# Connect destinations to shared network
123
-
docker network connect shared-network container1
124
-
docker network connect shared-network container2
125
-
```
47
+
1. **Find the Container Names**: There are multiple ways to find the container names. Here are two common methods:
126
48
127
-
#### Option 2: External Communication
128
-
Use external endpoints through the proxy:
129
-
```bash
130
-
# Application A calls Application B through external URL
131
-
curl https://app-b.example.com/api/endpoint
132
-
```
49
+
- Go the terminal of your server and run `docker ps` to list all running containers. Look for the names of your applications in the **NAMES** column.
50
+
Example output:
133
51
134
-
#### Option 3: Environment Variables
135
-
Pass connection details through environment variables:
136
-
```yaml
137
-
environment:
138
-
- EXTERNAL_API_URL=https://api.example.com
139
-
- INTERNAL_DB_HOST=database.internal
140
52
```
53
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
54
+
123456789abc nextjs-app:latest "docker-entrypoint.s…" 2 hours ago Up 2 hours 80/tcp my-nextjs-app
55
+
abcdef123456 express-api:latest "docker-entrypoint.s…" 2 hours ago Up 2 hours 3001/tcp my-express-api
56
+
```
57
+
58
+
- Navigate to the `Logs` tab of each resource in the Coolify dashboard and copy the container names from the header.
59
+
60
+
2. **Determine the Internal Port**: Use the port Express listens on internally (e.g., port 3001), not the external published port
61
+
62
+
3. **Build the Connection String**: `http://[container-name]:[internal-port]`
63
+
64
+
- Example: `http://my-express-api:3001`
65
+
66
+
4. **Use in Your App**: Configure your Next.js app to call the Express API using this internal URL instead of the external domain
67
+
68
+
This same pattern applies to any two applications (databases, APIs, microservices) within the same destination - always use the container name and internal port for communication.
69
+
70
+
::: info Service Stacks
71
+
If you have a Service Stack (deployments using Docker Compose), that needs to connect to a different resource outside of it's stack, you will have to first enable [Connect To Predefined Networks](knowledge-base/docker/compose#connect-to-predefined-networks) in the Service Stack settings.
0 commit comments