D
D
dobromin2022-02-02 16:07:17
Docker
dobromin, 2022-02-02 16:07:17

How to run docker with proxy and network interfaces?

How do I run docker with my network interfaces so that I can further customize the routing? I need to be able to access the Internet through docker.

We deploy the server, openvpn on it, docker on it with its own networks and connection to proxy servers. User 1 connects to vpn server and is routed through docker1 by firewall. Thus, the user accesses the network through proxy 1. And so for the nth number of users, there may of course be simpler solutions without the use of specialized software and microtics, which I was previously advised to "Try"

Now the config is

version: "3.9"
services:
  prixy_debian_vpn_user_11:
    container_name: prixy_debian_vpn_user_11
    image: debian:11
    environment:      
      HTTP_PROXY: 'http://vpn:[email protected]:1111'
      HTTPS_PROXY: 'http://vpn:[email protected]:2222'
      NO_PROXY: 'localhost'
networks:
      back:
        ipv4_address: 172.16.238.2
services:
  prixy_debian_vpn_user_22:
    container_name: prixy_debian_vpn_user_22
    image: debian:11
    environment:      
      HTTP_PROXY: 'http://vpn:[email protected]:3333'
      HTTPS_PROXY: 'http://vpn:[email protected]:4444'
      NO_PROXY: 'localhost'
networks:
      back:
        ipv4_address: 172.16.238.3
networks:
#Internal-only network for proper nginx proxying and ssh
  back:
    driver: bridge
    internal: false
    ipam:
     driver: default
     config:
     - subnet: 172.16.238.0/24 
     - gateway: 172.16.238.1
#External network actually
  default:
    driver: bridge


When running docker, I can't see the 172.16.238.3 network and network interfaces. while there is an error
WARNING: Some networks were defined but are not used by any service: back


Maybe I didn’t set up the network correctly in general, in my understanding the following should happen
where the comment #Internal-only network for proper nginx proxying and ssh
are internal networks that should appear as virtual LAN interfaces
where #External network actually
is an external interface that is combined bridge with the main interface of the server that looks at the Internet.
After a successful lift, I can see the docker network and all that remains is to configure the routing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2022-02-02
@karabanov

this is an external interface that is bridged with the main interface of the server that looks at the Internet.

It is already available from the host machine. You can add a rule to the firewall.
You can also forward ports through Docker-proxy to the host machine ( ports more details directive )
You can disable network isolation and use the host machine interfaces directly (directive network_mode: host).
PS
Try this:
networks:
  back:
    name: back
    driver: bridge
    ipam:
      driver: default
      config:
      - subnet: 172.16.238.0/24
        gateway: 172.16.238.1
    driver_opts:
      com.docker.network.bridge.name: back

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question