0

Hello there,

I am trying to dockerize a node application. I created two containers and a docker-compose.yml file. The containers are build successfully and run but the one should interact a host process. How is this possible?

Thanks in regard

UPDATE 1
My application runs some commands with sudo. Probably I have to let docker container execute commands that target host system. Any ideas?

  • What do you mean by `should interact with a host process`? Should they interact using HTTP? Some other RPC API? – YoavG Jun 02 '19 at 06:31

3 Answers3

0

I assume that by interact with a host process, you mean interaction over some network protocol thus you will need access to the host's IP address from the container.

The host computer's IP is the default gateway of the container in case you are using docker's bridge network. This would be the case if you did not provide specific network configuration inside your docker-compose.yml (https://docs.docker.com/compose/compose-file/#network-configuration-reference)

Since you are using node.js, you can use the default-gateway package (https://www.npmjs.com/package/default-gateway) to obtain this IP.

YoavG
  • 164
  • 1
  • 7
0

You can't execute host applications within your containers. Because they're not in your containers filesystem and you shouldn't try to do that. Instead you should install all the necessary softwares your app needs inside your docker container as dependency for your application.

chubock
  • 834
  • 8
  • 16
0

You could use a sock file, used for interprocess communication, and handle it to the container, similar to what watchtower does to control the docker daemon. Maybe you'll have to create a simple application to pipe the shell to the sock file and have it installed on the host to serve the container.

sock files: What are .sock files and how to communicate with them

watchtower: https://github.com/containrrr/watchtower

Diego Medeiros
  • 463
  • 5
  • 9