networking - Network connectivity for docker containers on Ubuntu VM -


i have installed docker on ubuntu vm. running ubuntu docker containers. ip address taken these docker container in 172.17.*.* (eth0). ip not able ping/access docker container outside.
hence trying assign ip local network range. followed steps:

  • create new bridge network subnet , gateway ip block

    $ docker network create --subnet 10.255.*.0/24 --gateway 10.255.*.254 ipstatic

  • run ubuntu container specific ip in block

    $ docker run --rm -it --net ipstatic --ip 10.255.*.2 phusion/ubuntu

  • curl ip other place (assuming public ip block duh)

    $ curl 10.255.*.2

curl: (7) failed connect 10.255.*.2 port 80: connection refused

with this, host unable access 10.255.*.* network.the docker container takes ip 10.255.*.2, still unable access outside. newbie docker. aim access docker containers to-from local network.

you can specify network_mode: "host" when create container. available @ same ip host. have make sure doesn't try listen port that's in use.

eg:

version: "2" services:   myapp1:     network_mode: "host"     etc 

however, it's practice treat host fortress , limit containers directly accessible outside world. keep nginx @ public face instance , keep other containers in private internal network. wrote answer few minutes ago.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -