-
Notifications
You must be signed in to change notification settings - Fork 17
/
day2.txt
180 lines (75 loc) · 4.09 KB
/
day2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Day2
=======
Docker Networking
==================
1.bridge
2.host
3.none
Usage: docker network COMMAND
Manage networks
Commands:
connect Connect a container to a network
create Create a network
disconnect Disconnect a container from a network
inspect Display detailed information on one or more networks
ls List networks
prune Remove all unused networks
rm Remove one or more networks
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
bf1fbfe96a65 bridge bridge local
d65a1441fd36 host host local
5bbef6bbb2b0 none null local
Default Bridge Network
========================
A bridge network uses a software bridge which allows containers connected to the same bridge network to communicate, while providing isolation from containers which are not connected to that bridge network.
The Docker bridge driver automatically installs rules in the host machine so that containers on different bridge networks cannot communicate directly with each other
It is the Docker default networking mode which will enable the connectivity to the other interfaces of the host machine as well as among containers.
docker run --name a-centos -it centos bash
docker run --name b-centos -it centos bash
docker start a-centos b-centos
Custom Bridge Network
========================
User-defined bridges provide automatic DNS resolution between containers.
User-defined bridges provide better isolation.
Containers can be attached and detached from user-defined networks on the fly.
Each user-defined network creates a configurable bridge.
Linked containers on the default bridge network share environment variables.
docker network create pradeep-network -d bridge
docker network create pradeep-network
docker run --name c-centos --network pradeep-network -it centos bash
docker run --name d-centos --network pradeep-network -it centos bash
docker start c-centos d-centos
docker network connect pradeep-network a-centos
docker network connect pradeep-network b-centos
docker network disconnect bridge a-centos
docker network disconnect bridge b-centos
docker network disconnect pradeep-network a-centos
docker network disconnect pradeep-network b-centos
docker network disconnect pradeep-network c-centos
docker network disconnect pradeep-network d-centos
docker network rm pradeep-network
docker network prune
None Network
==============
If you want to completely disable the networking stack on a container, you can use the --network none flag when starting the container.This mode will not configure any IP for the container and doesn’t have any access to the external network as well as for other containers. It does have the loopback address and can be used for running batch jobs.
docker run --name e-centos --network none -it centos bash
docker run --name a-nginx -p 1111:80 -d nginx
docker run --name c-nginx -p 2222:80 -d nginx
docker run --name d-nginx -p 3333:80 -d nginx
docker run --name e-nginx -p 3333:80 -d nginx
Host Network
============
In this mode container will share the host’s network stack and all interfaces from the host will be available to the container. The container’s host name will match the host name on the host system
docker run --name f-nginx --network host -d nginx
docker run --name f-nginx --network host -p 3232:80 -d nginx
docker run --name g-nginx --network host -p 7777:80 -d nginx
docker run --name i-nginx --network none -d nginx
Creating Custom Image
======================
Image:(Base OS + Application + Bin & Librainries)
1.From Container
==================
docker run --name p-nginx -p 8888:80 -d nginx
docker commit -m "Done changes to container" -a "Pradeep Chinchole" p-nginx pradeepch82/pvc-docker-demo:1.1
docker run -p 1111:80 -d pradeepch82/pvc-docker-demo:1.1