domingo, 7 de julio de 2019

Docker Host network

Docker Host Network

   Docker Host Network es la modalidad de red donde el contenedor se fusiona con la red del host, pero almacenamiento, process namespace y username space están aislados del host.

El contenedor se removerá automaticamente al detenerse y correra en background.
bext@bext-VPCF13WFX:~$ docker run --rm -d --network host --name my_nginx nginx
b89afa6c2915f41c9a53b3585d4fed8f63d9b3841d81fd90d354a06eadb5d3d0

bext@bext-VPCF13WFX:~$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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
2: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 78:84:3c:cc:07:0c brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 4c:0f:6e:f8:ba:40 brd ff:ff:ff:ff:ff:ff
    inet 10.143.113.239/8 brd 10.255.255.255 scope global dynamic noprefixroute wlp2s0
       valid_lft 79126sec preferred_lft 79126sec
    inet6 fe80::a463:87c:85cb:d377/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
4: docker_gwbridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:1c:26:76:ce brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global docker_gwbridge
       valid_lft forever preferred_lft forever
    inet6 fe80::42:1cff:fe26:76ce/64 scope link 
       valid_lft forever preferred_lft forever
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:a0:ac:f7:f5 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:a0ff:feac:f7f5/64 scope link 
       valid_lft forever preferred_lft forever
12: vetha135868@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker_gwbridge state UP group default 
    link/ether 3a:bd:92:ba:38:5a brd ff:ff:ff:ff:ff:ff link-netnsid 1
    inet6 fe80::38bd:92ff:feba:385a/64 scope link 
       valid_lft forever preferred_lft forever
bext@bext-VPCF13WFX:~$ sudo netstat -tulpn | grep 80
[sudo] password for bext: 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      9772/nginx: master  

Vemos que el servidor nginx esta usando el puerto 80 del host.

bext@bext-VPCF13WFX:~$ curl http://localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    } 
... 



Detenemos el contenedor y automaticamente se eliminará.

bext@bext-VPCF13WFX:~$ docker container stop my_nginx
my_nginx


eot

No hay comentarios:

Publicar un comentario