Образовательный проект «SnakeProject» Михаила Козлова

Навигация

⇒ FreeBSD and Nix ⇐

CISCO

Voice(Asterisk\Cisco)

Microsoft

Powershell

Python

SQL\T-SQL

Общая

WEB Разработка

ORACLE SQL \ JAVA

Мото

Стрельба, пневматика, оружие

Саморазвитие и психология


Docker: сеть типа мост


 

Docker: сеть типа мост


Создадим контейнеры в сети типа мост и проверим доступность к ним между контейнерами и с сервера с Docker

Создаем сеть типа мост:
docker network create --subnet 10.0.3.0/24 --gateway=10.0.3.1 --ip-range 10.0.3.0/24 --driver=bridge MyNet


docker network ls | grep MyNet
3957e1450211  MyNet  bridge  local


Делаем два хоста, один вебсервер, доступность которого будем проверять:
vi docker-compose.yml
version: '3.1'

services:
  nginx:
    image: nginx:latest
    container_name: nginx
    restart: always
    ports:
      - 80:80
    networks:
        MyNet:
          ipv4_address: 10.0.3.10
  app:
    image: busybox
    command: wget -q -O- http://10.0.3.10:80
    networks:
      MyNet:
        ipv4_address: 10.0.3.20
        

networks:
  MyNet:
    external:
      name: MyNet

 

Проверяем:
docker-compose up --build
Starting nginx ... done
Recreating docker_app_1 ... done
Attaching to nginx, docker_app_1
nginx    | 10.0.3.20 - - [07/Feb/2019:13:58:28 +0000] "GET / HTTP/1.1" 200 612 "-" "Wget" "-"
app_1    | <!DOCTYPE html>
app_1    | <html>
app_1    | <head>
app_1    | <title>Welcome to nginx!</title>
app_1    | <style>
app_1    |     body {
app_1    |         width: 35em;
app_1    |         margin: 0 auto;
app_1    |         font-family: Tahoma, Verdana, Arial, sans-serif;
app_1    |     }
app_1    | </style>
app_1    | </head>
app_1    | <body>
app_1    | <h1>Welcome to nginx!</h1>
app_1    | <p>If you see this page, the nginx web server is successfully installed and
app_1    | working. Further configuration is required.</p>
app_1    |
app_1    | <p>For online documentation and support please refer to
app_1    | <a href="http://nginx.org/">nginx.org</a>.<br/>
app_1    | Commercial support is available at
app_1    | <a href="http://nginx.com/">nginx.com</a>.</p>
app_1    |
app_1    | <p><em>Thank you for using nginx.</em></p>
app_1    | </body>
app_1    | </html>
docker_app_1 exited with code 0
^CGracefully stopping... (press Ctrl+C again to force)
Stopping nginx ... done

docker-compose up
Starting nginx ... done
Starting docker_app_1 ... done
Attaching to nginx, docker_app_1
nginx    | 10.0.3.20 - - [07/Feb/2019:13:58:43 +0000] "GET / HTTP/1.1" 200 612 "-" "Wget" "-"
app_1    | <!DOCTYPE html>
app_1    | <html>
app_1    | <head>
app_1    | <title>Welcome to nginx!</title>
app_1    | <style>
app_1    |     body {
app_1    |         width: 35em;
app_1    |         margin: 0 auto;
app_1    |         font-family: Tahoma, Verdana, Arial, sans-serif;
app_1    |     }
app_1    | </style>
app_1    | </head>
app_1    | <body>
app_1    | <h1>Welcome to nginx!</h1>
app_1    | <p>If you see this page, the nginx web server is successfully installed and
app_1    | working. Further configuration is required.</p>
app_1    |
app_1    | <p>For online documentation and support please refer to
app_1    | <a href="http://nginx.org/">nginx.org</a>.<br/>
app_1    | Commercial support is available at
app_1    | <a href="http://nginx.com/">nginx.com</a>.</p>
app_1    |
app_1    | <p><em>Thank you for using nginx.</em></p>
app_1    | </body>
app_1    | </html>
docker_app_1 exited with code 0
^CGracefully stopping... (press Ctrl+C again to force)
Stopping nginx ... done

 

С сервера с Docker:
curl 10.0.3.10:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

 


Комментарии пользователей

Эту новость ещё не комментировалиНаписать комментарий
Анонимам нельзя оставоять комментарии, зарегистрируйтесь!

Контакты Группа ВК Сборник материалов по Cisco, Asterisk, Windows Server, Python и Django, SQL и T-SQL, FreeBSD и LinuxКод обмена баннерами Видео к IT статьям на YoutubeВидео на другие темы Смотреть
Мои друзья: Советы, помощь, инструменты для сис.админа, статическая и динамическая маршрутизация, FreeBSD

© Snakeproject.ru создан в 2013 году.
При копировании материала с сайта - оставьте ссылку.

Рейтинг@Mail.ru
Рейтинг@Mail.ru Яндекс.Метрика





Поддержать автора и проект