[ BAEL-6068 ] - Communicating with Docker containers on the same machine (#13343)
* fix: build clean up * feat: add docker compose 2 module, add communication same machine docker compose * fix: remove unused package lock file
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
services:
|
||||
alpine-app-1:
|
||||
container_name: alpine-app-1
|
||||
extra_hosts: # for linux hosts since version 20.10
|
||||
- host.docker.internal:host-gateway
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile
|
||||
image: alpine-app-1
|
||||
tty: true
|
||||
networks:
|
||||
- first-network
|
||||
|
||||
node-app:
|
||||
container_name: node-app
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile.node
|
||||
image: node-app
|
||||
ports:
|
||||
- 8080:8080
|
||||
networks:
|
||||
- second-network
|
||||
|
||||
networks:
|
||||
first-network:
|
||||
driver: bridge
|
||||
second-network:
|
||||
driver: bridge
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
var express = require('express')
|
||||
var app = express()
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('Hello World!')
|
||||
})
|
||||
|
||||
app.listen(8080, function () {
|
||||
console.log('app listening on port 8080!')
|
||||
})
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "host_docker_internal",
|
||||
"version": "1.0.0",
|
||||
"description": "node js app",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Baeldung",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "^4.18.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user