I created some network with these command :
docker network create --driver bridge my-network
and I have some docker image that already created with an dockerfile.
In docker documentation they said you can connect your container with this command:
docker run --network=my-network -itd --name=mycontainer busybox
in my nodejs I need to pass these args to my run function:
let options = ['some option']
docker.run('mycontainer', [], process.stdout, { Env: options }).then(data => {
console.log(data)
}).catch(err => { console.log(err) })
so return to my main question : How to join a docker to docker network ?
The last parameter "{ Env: options }" is used for that.
it refers to Docker API : https://docs.docker.com/engine/api/v1.24/#31-containers Look at 'Create container' --> The last part of the request is 'NetworkingConfig'. You still have to found the good syntax in your JS app
Something like :
let options = ['some option']
docker.run('mycontainer', [], process.stdout, {
Env: options,
NetworkingConfig: {
"EndpointsConfig": {
"isolated_nw" : {
"IPAMConfig": {
"IPv4Address":"172.20.30.33",
"IPv6Address":"2001:db8:abcd::3033",
"LinkLocalIPs":["169.254.34.68", "fe80::3468"]
},
"Links":["container_1", "container_2"],
"Aliases":["server_x", "server_y"]
}
}
}}).[...]