Docker Networking Examples

Step1: create a docker Bridge called mybridge1
Step2: Run the containers with network option to attach to this bridge, simultaneously multiple containers can be attached to the same bridge if the "name" of container is correctly configured.
Below example I have used the image ID which I have pulled to my AWS EC2 machine.
root@ip-172-31-14-141:~# docker run -itd --network=mybridge1 fc8ac8dec8ba
0712be8d028d6f049a2cab78078a054f65703195b1bd2e4912bc10972b34181c
root@ip-172-31-14-141:~# docker ps -a
CONTAINER ID        IMAGE                  COMMAND             CREATED             STATUS                           PORTS               NAMES
0712be8d028d        fc8ac8dec8ba           "/bin/bash"         5 seconds ago       Up 5 seconds        

root@ip-172-31-14-141:~# docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
0712be8d028d        fc8ac8dec8ba        "/bin/bash"         15 seconds ago      Up 15 seconds                           grave_kowalevski

root@ip-172-31-14-141:~# docker run -itd --network=mybridge1 angularjs-dev:latest
a77b0bedc64ae144287ba0257fa4662e25c37c848afe37221b8af501b820ce76

root@ip-172-31-14-141:~# docker ps 
CONTAINER ID        IMAGE                  COMMAND             CREATED              STATUS              PORTS               NAMES
a77b0bedc64a        angularjs-dev:latest   "/bin/bash"         4 seconds ago        Up 3 seconds                            high_ptolemy
0712be8d028d        fc8ac8dec8ba           "/bin/bash"         About a minute ago   Up About a minute                       grave_kowalevski

root@ip-172-31-14-141:~# docker exec a77b0bedc64a ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
41: eth0@if42: mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:12:00:03 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.3/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe12:3/64 scope link 
       valid_lft forever preferred_lft forever
root@ip-172-31-14-141:~# docker exec 0712be8d028d ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
39: eth0@if40: mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:12:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.2/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe12:2/64 scope link 
       valid_lft forever preferred_lft forever

root@ip-172-31-14-141:~# docker exec 0712be8d028d ping 172.18.0.3

PING 172.18.0.3 (172.18.0.3): 56 data bytes
64 bytes from 172.18.0.3: icmp_seq=0 ttl=64 time=0.096 ms
64 bytes from 172.18.0.3: icmp_seq=1 ttl=64 time=0.075 ms
64 bytes from 172.18.0.3: icmp_seq=2 ttl=64 time=0.070 ms
64 bytes from 172.18.0.3: icmp_seq=3 ttl=64 time=0.071 ms

Tested the communication with Pinging one container to the other











Github Local server to Github PUSH



  1. 1.Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.
  2. 2. Open TerminalChange the current working directory to your local project.
  3. in my case "hellonode" is my Project Directory
  4. cd /hellonode/
  5. 3. Initialize the local directory as a Git repository.
    git init
    
  6. Add the files in your new local repository. This stages them for the first commit.
[root@localhost hellonode]#git add .
 

[root@localhost hellonode]#git commit -m "First Commit"


[root@localhost hellonode]# git remote add origin https://github.com/jskcbe/nodejs.git

[root@localhost hellonode]# git remote -v
origin  https://github.com/jskcbe/nodejs.git (fetch)
origin  https://github.com/jskcbe/nodejs.git (push)         (jskcbe is my github account)

[root@localhost hellonode]# git push origin master
Username for 'https://github.com': jskcbe
Password for 'https://jskcbe@github.com':
Counting objects: 9601, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8929/8929), done.
Writing objects: 100% (9601/9601), 30.80 MiB | 679.00 KiB/s, done.
Total 9601 (delta 2088), reused 0 (delta 0)
remote: Resolving deltas: 100% (2088/2088), done.
To https://github.com/jskcbe/nodejs.git
 * [new branch]      master -> master
[root@localhost hellonode]#
The Code from your local Server is now pushed to the GitHub Repository..
Whenever there is a code change in your local directory, you can initiate a build with that using JENKINS

Installing Ingress Controller - Kubernetes

Installing the Ingress Controller Prerequisites Make sure you have access to the Ingress controller image: For NGINX Ingress controll...