Skip to content

Commit d4e55d5

Browse files
committed
Access Local Services in Docker
1 parent 3768334 commit d4e55d5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [UNRELEASED]
44
### Changes
55

6+
- [Access Local Services in Docker](https://docs.appseed.us/technologies/docker/access-local-services/)
67
- [Debugging Flask](https://docs.appseed.us/technologies/flask/debugging/) `Guide for Developers`
78

89
## [1.0.68] 2023-10-25
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title : Docker - Access Local Services
3+
sidebar_label : Access Local Services
4+
---
5+
6+
# Docker - Access Local Services
7+
8+
<SubHeading>Learn how to access host servcies from a docker container.</SubHeading>
9+
10+
Sometimes, having a Dockerized project, we might need to access local sevices like Redis, MySql or PostgreSQL.
11+
This use case is supported by Docker when we set in the environment the **hostname** to **host.docker.internal** instead of using the traditional `localhost` or `127.0.0.1` witch might lead to runtime errors like this:
12+
13+
`connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address`
14+
15+
<br />
16+
17+
> Some well-known local services we can access from a **Docker Container**
18+
19+
- **Redis**: port `6379`, hostname **host.docker.internal**, instead of `localhost`
20+
- **MySql**: port `3306`, hostname **host.docker.internal**, instead of `localhost`
21+
- **Postgresql**: port `5432`, hostname **host.docker.internal**, instead of `localhost`
22+
23+
![Docker, Access Local Services - Tutorial provided by AppSeed](https://github-production-user-asset-6210df.s3.amazonaws.com/51070104/268558520-a87dbf5e-83a8-4daf-9b10-8417b58c60e1.png)
24+
25+
<br />
26+
27+
## ✅ Resources
28+
29+
- 👉 Read more about [Docker](/technologies/docker/)
30+
- 👉 Access [AppSeed](https://appseed.us/) for more starters and support
31+
- 👉 [Deploy Projects on Aws, Azure and DO](https://www.docs.deploypro.dev/) via **DeployPRO**

0 commit comments

Comments
 (0)