The Docker Bridge Network - Docker networks part 1

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ก.ค. 2024
  • MANY THANKS TO ALL MY PATRONS on / onemarcfifty !!!
    Many thanks for your replies to the poll - your wish is my command and here is the episode on docker networks. As there is so much to tell about docker networks, we will talk about Bridges in this episode. In the next episode we will talk about the host and macvlan network. Networking with Docker, docker bridge networks and docker host and macvlan networks as well as docker-compose are subjects of this series. We will define the networks in the Portainer Networking section
    0:00 Intro
    1:23 TLDR / TLDW / Chapters
    1:42 Describing the setup nginxdemos/hello
    2:08 What do we need ?
    3:10 Pull the image
    4:00 examining the container
    5:33 IP Connectivity on the bridge
    7:30 Network access
    7:55 Hostnames
    8:33 Name resolution default bridge
    9:22 Port mapping
    10:15 The bridge is NAT-ed
    11:10 user defined bridges
    13:26 Summary bridges
    14:00 automate with docker-compose
    18:03 Outlook, wrap-up
    Here's the list of the commands / steps used in the video:
    Portainer Documentation is here: documentation.portainer.io/v2...
    sudo apt install docker.io
    (on a Pi it may be called docker-ce)
    One liner to start portainer:
    docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce
    (In portainer, click on "Networks" on the left, you'll see the networks)
    (on the command line)
    docker network ls
    (Pulling the image and running it)
    docker run -d nginxdemos/hello
    (in Portainer, Containers Menu, then "Add Container")
    (Finding the IP address - click on the container name in Portainer)
    Default Bridge IP is usually 172.17.0.0/24, the docker host is 172.17.0.1
    (Click on the container name and Select "Duplicate/Edit" to clone it)
    In order to execute shell (/bin/ash) on the command line
    docker exec -it CONTAINERNAME /bin/ash
    Commands I type INSIDE the containers:
    ip addr
    hostname
    ip route
    ping 172.17.0.x
    ping 8.8.8.8
    ping www.google.com
    Create the image with port mapping and container name:
    docker run -d --name nginx1 -p 81:80 nginxdemos/hello
    docker run -d --name nginx2 -p 82:80 nginxdemos/hello
    (now you can browse to localhost:81 or localhost:82)
    Create the bridge network:
    docker network create -d bridge --subnet 172.172.0.0/24 --gateway 172.172.0.1 --ip-range 172.172.0.128/25 --attachable marcsbridge
    In order to run the containers on the user defined bridge:
    docker run -d --name nginx1 -p 81:80 --network marcsbridge nginxdemos/hello
    docker run -d --name nginx2 -p 82:80 --network marcsbridge nginxdemos/hello
    Install docker-compose:
    sudo apt install docker-compose
    The docker compose file can be found here: github.com/onemarcfifty/docke...
    The Microsoft Visual Studio Code Site is here: code.visualstudio.com/Download
    (Download the .deb for Ubuntu/Debian, you will then find the File in your Downloads directory. You can then install it with):
    sudo dpkg -i (Filename)
    for example
    sudo dpkg -i code_1.56.0-1620166262_amd64.deb
    In order to have the docker-compose extension in Visual Studio Code, select View-Extensions. There are many extensions available, e.g. "Docker Extension Pack" or "Docker Explorer" by Jun Han, or "Docker" by Microsoft or "Docker Compose" by p1c2u
    Command line compose up :
    docker-compose -f "docker-compose.yml" up -d --build
    Please support me on patreon: / onemarcfifty
    My youtube channel: / onemarcfifty
    Marc on Twitter: / onemarcfifty
    Marc on Facebook: / onemarcfifty
    Marc on Reddit: / onemarcfifty
    Chat with me on Discord: / discord
    Licence-free music on / Lizenzfreie Musik von www.terrasound.de/lizenzfreie... music on / Lizenzfreie Musik von www.terrasound.de/lizenzfreie...
    The docker logo from Wikimedia Commons By dotCloud, Inc. - File:Docker (container engine) logo.png, Apache License 2.0, commons.wikimedia.org/w/index...
    The Thumbnail of this video is under the Apache 2.0 License: www.apache.org/licenses/LICEN...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 129

  • @jacksonmacd
    @jacksonmacd ปีที่แล้ว +2

    I will join the chorus of voices who have stumbled in the dark until discovering your videos. Well done, thank you very much for quality content. I like the pace and the hands-on approach.

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Hi Jack, thanks a lot for the friendly feedback - much appreciated ;-)

  • @gotelldonn
    @gotelldonn 2 ปีที่แล้ว +5

    Incredibly clear information on docker networks. Keep up the great work!

  • @jeytis72
    @jeytis72 3 ปีที่แล้ว +1

    Awesome! I have never come across such a clear explanation on how dockers and docker networks work. Thank you very much

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว +1

      Many thanks for your kind feedback! I am glad you liked it ;-)

  • @johnu730
    @johnu730 2 ปีที่แล้ว +1

    After watching other explanations on Docker Bridge Networks and not understanding, this video explains it perfectly !
    Excellent

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว

      Awesome, many thanks ! I am glad it helped !

  • @ivanhansson2195
    @ivanhansson2195 2 ปีที่แล้ว +6

    So impressed of your way of explain things. Keep up the good work!

  • @krishnapanjiyar7789
    @krishnapanjiyar7789 2 ปีที่แล้ว +3

    This is the best docker networking tutorial available in the web. I became a big fan of yours.

  • @TradersTradingEdge
    @TradersTradingEdge 3 ปีที่แล้ว +3

    What a brilliant and nice lesson Marc.
    Thanks very much, you are a great teacher and everyone can feel that you put much heart into the lessons.
    I hope you continue your muse for a long time.
    Happy Weekend :)

  • @JoaquinVacas
    @JoaquinVacas 2 ปีที่แล้ว +1

    I've just found this channel and I really enjoy every damn video.
    Thank you so much!
    A firmly handshake from Spain! 🇪🇸

  • @tonybell1597
    @tonybell1597 3 ปีที่แล้ว +4

    Fantastic Marc….. going to have a play with this, it’s been one of those “dark arts” thank you.

  • @dharunpazhanivel4727
    @dharunpazhanivel4727 3 ปีที่แล้ว +1

    Just waiting for your next episode on this. I love your work Marc 👍👍👍👍

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว

      Thank you very much for your kind feedback! I have just published the second episode yesterday - sorry I am a bit short on time these days, so the frequency of videos has gone down a bit - desperately waiting for my summer vacation to catch up here ;-)

  • @unmesh59
    @unmesh59 2 ปีที่แล้ว +1

    I've just started to learn Docker and used this tutorial on an Ubuntu 21.04 VM running on ESXi7. I couldn't believe how much I learned in a very short time!
    Thanks, Marc.

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว

      Awesome, many thanks for your feedback!

  •  ปีที่แล้ว +5

    This 2 part tutorial are the first of your videos I watch. I have been self-training in docker for the last few weeks and these are the best introduction to the topic of docker networking I have found by far. Love the hands on approach with exercises that really help get the notions clarified. Bravo! subscribed now.

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Hi Cédric, many thanks ;-)

    • @Nicsiq
      @Nicsiq 10 หลายเดือนก่อน

      I 2nd this! Thanks!

  • @cursoderobotica
    @cursoderobotica 2 ปีที่แล้ว +1

    Amazing tutorial!! I loved the comparison between portainer and the comand line!! Now I have the networking clear!! Thank you

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว

      Awesome - many thanks for the feedback. Glad it worked out ;-)

  • @jairunet
    @jairunet 2 ปีที่แล้ว +1

    Excellent and to the point, I never used portainer before seems to be a good alternative to the CLI, very good to know and to have it in the bag of management tools. Looking forward to part 2, thank you for the awesome content Marc.

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว +1

      Hi Jairu, yes - I love portainer - I do not necessarily use it to create containers but it's great for everything else ;-)

  • @Alt0004
    @Alt0004 3 ปีที่แล้ว +1

    Great video, cannot wait for the next on macvlan!

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว

      Hi Timothy, just published it yesterday ;-)

  • @GeorgeKaranikos
    @GeorgeKaranikos 3 ปีที่แล้ว +1

    legend. great level of detail, welll explained. love your work

  • @djjmahon
    @djjmahon 2 ปีที่แล้ว +1

    Thank you Marc - very informative and well-presented.

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว

      Thank you very much David!

  • @cumsaviata8145
    @cumsaviata8145 2 ปีที่แล้ว +1

    Well done! I enjoyed watching it, learned new things as well.

  • @MikePacholik
    @MikePacholik 3 ปีที่แล้ว +2

    Thank you. I have been wondering how networking worked in Docker. I learned so much.

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว

      Many thanks for your feed back Mike !!!

  • @daysiewaysie
    @daysiewaysie ปีที่แล้ว +1

    really enjoyed watching this one. having spent a couple of weeks clicking around in portainer and not being quite sure how the interface & the options dovetail with docker input on the CLI or using docker-compose, this clearly explained and engaging video has helped tremendously to demystify. And i also learned some of the fundamentals of docker networking also.
    when at first a topic seems unfathomable, there is a sudden lightbulb-moment when it all begins to make sense. the demystification process (the rolling back of the fog) is to a greater extent attributable of the abilities of teacher. i'm guessing you are a teacher by profession (?). Many thanks Marc for the time and effort you have put into sharing your knowledge. without hesitation, i have subscribed.

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Hi, first off many thanks for your feedback and for subscribing! No, I am not a teacher ;-) I work as a Presales consultant for a software vendor ;-)

  • @SenoClub
    @SenoClub 3 ปีที่แล้ว +1

    You are the best instructor! thanx for you work!

  • @kaybax4623
    @kaybax4623 2 ปีที่แล้ว +1

    This was very instructive and easy to follow. Thank you.

  • @irtibatkisileri222
    @irtibatkisileri222 2 ปีที่แล้ว +1

    how nicely you put topics thanks.

  • @leemiller7165
    @leemiller7165 2 ปีที่แล้ว +1

    Very informative, thank you. There are far too many videos out there that are just like "use host" or "use bridge" and never explain why. Then if things don't work you're left on your own to figure it out with no real understanding of what is going on.

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว

      Hi Lee, many thanks for your feedback. there's more on my channel page th-cam.com/channels/G5Ph9Mm6UEQLJJ-kGIC2AQ.html

  • @WyRura
    @WyRura 2 ปีที่แล้ว +1

    Great video, very well explained. Thank you.

  • @technology_consultant
    @technology_consultant 3 ปีที่แล้ว +1

    Really liked the way you described. Keep it up

  • @sunnyyang2174
    @sunnyyang2174 2 ปีที่แล้ว +1

    Great tutorial! Many thanks!!

  • @wlwplus9268
    @wlwplus9268 ปีที่แล้ว +1

    Excellent tutorials ! - Thank you ! "Keep on movin !"

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว +1

      Thank you - I will ;-)

    • @wlwplus9268
      @wlwplus9268 ปีที่แล้ว +1

      @@OneMarcFifty Das freut mich. Um gute Tutorials zu produzieren muss man die Materie beherrschen und in der Lage sein "Verständnishürden" zu erkennen und. zu kompensieren. Das gelingt Dir hervorragend.

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Cool, danke !

  • @flocassilla
    @flocassilla 3 ปีที่แล้ว

    Thanks for explaining all of this

  • @dylancampbell9631
    @dylancampbell9631 2 ปีที่แล้ว

    This was brilliant, thanks!

  • @squalazzo
    @squalazzo 3 ปีที่แล้ว +1

    very clear, well done, thanks!

  • @user-np2xe2ri4x
    @user-np2xe2ri4x ปีที่แล้ว +1

    Amazing content, thank you

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Hi Aleksei, thank you very much!

  • @etiennedeklerk
    @etiennedeklerk 2 ปีที่แล้ว +1

    this is just perfect thank you

  • @ndjung
    @ndjung 3 ปีที่แล้ว +1

    Thanks for videos. It explained a lot

  • @curtisaccord
    @curtisaccord 3 ปีที่แล้ว +1

    Docker network Macvlan, docker-compose, and mptcp server would be an amazing project to see.

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว +1

      The second episode has just been published yesterday ;-)

  • @gaborungvari784
    @gaborungvari784 3 ปีที่แล้ว

    thanks and keep creating !

  • @berndeckenfels
    @berndeckenfels 3 ปีที่แล้ว +4

    Great start to the series

  • @efantiefanti
    @efantiefanti 3 ปีที่แล้ว

    Thank you for your video

  • @dokomann
    @dokomann 3 ปีที่แล้ว +1

    darauf habe ich gewartet..

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว

      Hey Tom, awesome - I just published the second part yesterday ;-)

  • @MilosI
    @MilosI 3 ปีที่แล้ว

    sick content bro :D thx

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว +1

      May I take this as a compliment?

    • @MilosI
      @MilosI 3 ปีที่แล้ว

      @@OneMarcFifty ofc 😊

  • @JimmYJammA2099
    @JimmYJammA2099 ปีที่แล้ว +1

    Very interesting

  • @chrisdepalma6844
    @chrisdepalma6844 3 ปีที่แล้ว +2

    you should have more subscribers

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว

      Thank you very much Chris ;-)

  • @ghahramanrahebi2395
    @ghahramanrahebi2395 2 ปีที่แล้ว +1

    Excelent

  • @RifatErdemSahin
    @RifatErdemSahin 3 ปีที่แล้ว +1

    Great one. Any change to go over the question with rancher ? Keeping the socket open behind the loadbalance for docker networks ?

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว +1

      Thank you Erdem. Time is a bit of a constraint at the moment - still answering messages from the last 4 weeks ;-(

  • @ameenal-azzawi2180
    @ameenal-azzawi2180 3 ปีที่แล้ว +2

    I did the same steps on Windows 10 host, the IP address of the first container "172.17.0.4", doesn't show anything in the browser.

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว

      Ah - not sure about Windows here - the ip addresses might be different

  • @Anonymouzee
    @Anonymouzee ปีที่แล้ว +1

    Mark... this TH-cam/dudes won't let me like this video more than once... 😁 you must fix this!!!
    ,,, so... you get the 'cryptic' hostname and then ping the 'friendly' name... 😶‍🌫
    this way you confuse the audience...
    you should had ping the 'cryptic'... and pointed the ip,,,
    and next ping the the 'friendly'... and alert you go the same ip...
    ;-)

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Haha ;-) Thanks mate - and thanks for the advice ;-)

  • @paurushgargtube
    @paurushgargtube ปีที่แล้ว +1

    Thanks for the wonderful explanation. However @4.44 I didn't get any response after hitting the ip of the container through browser. Not sure why so.

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Did you try and access it from another machine or locally on the docker host ? this only works on the machine itself.

  • @sebstiank.4454
    @sebstiank.4454 3 ปีที่แล้ว +1

    Great video and good information.
    I have one question. I have docker on my raspberry installed.
    When i install Visual Studio Code on my computer, how do i connect to the raspberry docker instance?

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว

      Hi, I am not sure if that is possible. Have you checked the Extensions page of Visual Studio Code ? The way I use the docker extension is that I test docker on my local system and once everything is OK I transfer the files. So I do not do in-place editing on the host.

  • @user-mv2hr9tj9i
    @user-mv2hr9tj9i 2 ปีที่แล้ว +1

    On "Compose Up" from vscode I got the error:
    "ERROR: Couldn't connect to Docker daemon - you might need to run docker-machine start default."
    After a while I managed to compose up from a terminal: "docker-compose -f "docker-compose.yml" up -d --build".
    Two containers were created which I could check with the terminal command "sudo docker container ls".
    Both work fine and I can reach them from a web browser, but I cannot see newly created containers in portainer.
    By the way the terminal command "sudo docker container ls" shows me only the containers created from the terminal, but not the containers created from portainer including the portainer itself.

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว

      Now that's interesting. Are you sure that you are connecting to the same docker instance with Portainer and the local docker ? Portainer created containers should show up just like normal containers. They are no different. Maybe try docker container ls -a in order to see all of them, including the ones that are not running ?

  • @quesder
    @quesder ปีที่แล้ว +1

    if the host IP is 172.17.0.1, and there is another machine on the same network with IP 172.17.0.2, then how could the host create a container with IP 172.17.0.2 inside the host itself? Wouldn't the host get confused with the two entities?

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      It depends on the routes that are set up on the host and which network adapter the IP is bound to.

  • @PS-xn8ej
    @PS-xn8ej 3 ปีที่แล้ว +1

    do you have experience with separate network in k8s clusters between namespaces ?

    • @OneMarcFifty
      @OneMarcFifty  3 ปีที่แล้ว

      Hi P S , no not really, I havent done much with Kubernetes.Pure Docker for the time being. Sorry ;-)

  • @Jindraxx20
    @Jindraxx20 ปีที่แล้ว +1

    Hello there ! Thank you for providing us with a great video again !!!
    I would like to ask a question though. If you have a file for example a .txt and you want to create a parser with a python container. How is it possible for the container to see and edit the file that is located in the linux OS outside the container ??
    I'm new to docker and containers sorry for my newbish question :)

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว +1

      Hi - typically you would either have the file in a docker volume (i.e. docker volume create xxxx) and attach it to the container or just attach it with -v as a bind mount. Like docker run -v /data:./data

    • @Jindraxx20
      @Jindraxx20 ปีที่แล้ว +1

      @@OneMarcFifty Thank you Marc, that's enough info in order for me to search more stuff and try asap the above suggested :)

  • @verygoodbrother
    @verygoodbrother ปีที่แล้ว +1

    For the ip range should it be 172.172.0.0/25 for the first half i.e. 172.172.0.0 to 172.172.0.126?

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Hi, could you give a reference / time marker or a context please of what you want to achieve?

    • @verygoodbrother
      @verygoodbrother ปีที่แล้ว

      @@OneMarcFifty Hi, at around 11:44

  • @hamhumtube
    @hamhumtube ปีที่แล้ว +1

    You say bridge network ips are accessible from outsite yet with the ip numbers on browser you accessed first two containers you deployed

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Hi - very well observed ;-) Yes, the container is not accessible from outside _the docker host_ but in this video docker is running directly on my workstation, hence I can access it from the local host.

    • @hamhumtube
      @hamhumtube ปีที่แล้ว +1

      @@OneMarcFifty thanks for clarification. In my first comment a “not” is missing (not accessible) even though you understood me the way I meant. I like our host’s engineering manner. Thanks as always

  • @robertdanzl
    @robertdanzl 2 ปีที่แล้ว +1

    Schade das es das Video nicht in deutsch gibt

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว +1

      Hallo Robert - ja, TH-cam unterstützt leider keine mehrfachen Audio- Spuren. Ich lade aber zu allen Videos die Text-Daten hoch, so daß die automatisch übersetzten Untertitel ziemlich akkurat sein sollten.

    • @robertdanzl
      @robertdanzl 2 ปีที่แล้ว +1

      @@OneMarcFifty vielen Dank für deine schnelle Antwort. Hab mir gerade angesehen, leider kann ich den Untertitel nur in Englisch auswählen. Mache ich da etwas falsch?

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว +1

      Hmmmm…. Geht tatsächlich auf dem Handy nicht - ich probiere es gleich auf dem PC - wenn’s da auch nicht geht habe ich vielleicht vergessen einen Haken zu setzen irgendwo - ich melde mich nochmal

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว +1

      OK ich hab das jetzt mal getestet - das Feature ist tatsächlich nur im Browser verfügbar, nicht in der TH-cam App ;-( Ich muss mal überlegen, ob ich für die "wichtigsten" Sprachen vor-übersetzte Untertitel anbieten kann (EN/DE/FR/ES/IT).

    • @robertdanzl
      @robertdanzl 2 ปีที่แล้ว

      @@OneMarcFifty danke für deine Mühe. Hab's im Browser aber auch nicht hinbekommen, hab bei Untertitel da als Sprache auch nur Englisch zur Auswahl.

  • @digitalhomecanada
    @digitalhomecanada ปีที่แล้ว +1

    A minute and a half, I shut it off Because you haven’t told me anything

    • @OneMarcFifty
      @OneMarcFifty  ปีที่แล้ว

      Hi Hugh, first off - many thanks for the honest feedback- I do appreciate it! Let me watch the video again and I‘ll come back to you. Maybe I was too long on the intro.

  • @jaysunkreuze1466
    @jaysunkreuze1466 2 ปีที่แล้ว +1

    You lost me at Microsoft. It's unnecessary.

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว

      Well - I understand Microsoft is kind of a no go to many in the Linux community. But I actually do like VS Code - Which IDE are you using ?

  • @yarbinmalawi8288
    @yarbinmalawi8288 2 ปีที่แล้ว +1

    I could not get it to work on WSL when I went to the IP address at 172.17.0.x

    • @OneMarcFifty
      @OneMarcFifty  2 ปีที่แล้ว

      I haven't tested this on WSL - might have a different IP there or maybe the Windows Firewall m*sses things up ?