-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker
226 lines (173 loc) · 8.93 KB
/
docker
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
Environment in which the product is developed is diffent than the production environment. Like OS, Security policies, SSL certificates. java versions.
Development and testing occurs on containers and these are pushed to production so the issue related to incompatibility dont arise in production. This makes possible faster release model and multiple technology stack.
Avoids problems caused by multiple versions of same platform(python, java versions) on sinlge host. Docker orchestrates the containers. Configurations of containers/launching/ deleting.
Docker uses only host OS kernals. It does not have its own OS.
Image -> Libraries -> Application Code #What is Container?
Containers are application centric way to deliver high performance , scalable application on infrastructure of your choice.
Its more than app virtualization.
Difference between virtual machine and containers?
Virtual machines are for longer term.
Containers are not for long duration. create and distroy easily.
containers consume less resources.
Virtualization technology:
Need to specify hardware like 1 GB RAM, and one HDD
.vhdx image (VHD: virtual harddisk)
Takes large space. ~1gb(windows) 400mb(Linux)
Cons:
Long time to boot up
lesser modularity
Fewer VMs on single server.
Quite heavy
Single entity works independently
Containerized technology:
No Guest OS, No Hypervisor as in VM
It use images of OS.
Small in size. ~100Mb
Have minimum from OS to run the application.
On linux we can create only Linux containers. I.e. Only container of Host Type can be created.
We can use containers in VM
If the containers are destroyed then we need to create new container from image.
Running image is called as container
On one server 50-60 VM created max
VM ware - horizon software - allows to create 150 containers
Pros:
Multiple containers can commnicate with each other
Multiple containers can refer to same image. Container optimization.
How about MySQL data access through the container if are on diferent container.-> create private network and register containers
COntainer is future : physical servers(Past) -> Virtualization (Present)
Docker is container management service.
Build.Ship.Run distributed applications.
Amazon EC2 is virtual machines
UCP: universal control plane -> UI based management. Comes with enterprise
Kinematic: UI based but basic compared to UCP
Mar2016 docker cloud: create containers in docker cloud
Mar17: Launched for production.
Commnunity edition (CE): Command based
Learning curve:
Why container?
Docker installation
Images and containers
Docker file
Docker compose
Volumes and networks
Docker swarms
Docker cloud
Installation:
Requires 64bit OS
In windows it will create Linux VM and everything is done within VM
On windows for VM one needs to have HyperVisor. HW should support Hyper-V in turns to install Docker.
1:04:03
Client -> Docker_Host -> Registry
Client :
Docker application
build/pull/run
By default memory resource are shared between containers. Can sepcify memory to specific container
DOCKER_HOST:
Docker daemon orchestrates containers and images
Computer running DockerEngine is the Docker Host
In windows the Docker host is the VM . MobyLinuxVM
In linux the machine will be docker host
Registry:
Docker regisrty. Docker Hub. official . All the images of docker. Images can be from one liner code to appliction to OS
There can be unofficial repositories too.
Server for Docker deamon to fetch the images or services
Image: is the readonly layer of OS that never changes.
Container:
Self contained environment build using multiple images. Containers can be created from multiple images
Docker file:
A file containing docker commands to create containers from images
nginx:Latest -> latest version of nginx
Image will occupy HDD and containers will use memory
Ports are connected to container. Container will be having seperate IP and treated as seperate machine.
Decide IP of docker by configuring docker network Bridge is default network. Can create different network.
Docker Hub:
hub.docker.com
Official repository provided by docker to share the images created by comunity members
can have multiple images of same application like mysql. Prefer official images. Use images with higher stars.
>Docker pull mysql:latest
>Docker pull mysql:8 #8 is called as tag
docker images #list images locally available
docker pull nginx
docker rmi <imageid> #delete or remove images from docker hub
docker inspect <imagename>
Pull image from hub -> put it in host -> launch the containers
Can maintain two versions of mysql using containers.
To persist the data but container is distroyed. We need to create volume which will be pointed by new container.
"commit" is used create image from container
repositories will be present in moby folder
Why container?
start mongodb databse and use it within application
to start ansible server
start mysql server
test application on newer version of framework
host LDAP server
host wordpress server
Running a container:
One process per container
application container and database container will communicate with the shared network. Docker network.
If one container gets down then other can take over
Container are short lived
>docker image pull ubuntu
>docker container run -it --name ubuntu ubuntu /bin/bash #-it -> interactive terminal, bin-bash is command
> docker container ls # list running containers
>docker stop da ##da initial of the container id
> docker container pause da
> docker container unpause da
> docker container stop da
> docker container ls
> docker stop da
> docker rm fc
> docker ps # >docker container ls #are same
>docker container run -d -p 8085:80 --name my_webserver nginx # in detached mode i.e. dont enter the container.-p fixed port.-P random port
>docker port mywebserver #to see Nginx port
>docker attach my_container #get inside if outside container
>docker stats #CPU,Memory ,Network usage
>docker inspect container_name # PID is of mobyLinux as every container is running as a process
>docker top <PID>
##Docker class room
docker compose # runs config yml file. can share the yml file to share the setup
Image is about the layers. Starts from base image and creates image for each image change in the form of application install. repository update
>docke container rm -f <ids>
DockerFile # is for creating single custom image
yml #compose file is used to crate multiple containers
>docker image build -t <acc name>/myImageName . # current directory of the image so "."
Updating host file does not work as container is not build on latest files. Can be overcome.
Pushing to the repository:
>docker login
>docker push myImageName
#linux command
cat /etc/issue
DOCKER SETUP STEPS:
Install Docker on windows
Create ubuntu VM using hyperv and boot2docker image.(Enable hyperV on windows first)
In the boot2docker VM docker deamon is already present.
Create dockerfile for selenium hub and chrome and firefox. Or create these indivudually and connect the browser VMs with hub and register as nodes.
Get the URL like below and use it in code/config file.
http://10.77.201.58:4444/wd/hub #here 10.77.201.58 is the host VM address and 4444 is the port on which hub is deployed.
DEPLOYMENT IDEA:
Checkin to Git/bitbucket
Add bitbucket path to bamboo/jenkins
Trigger build per IR
This build will have pre-build dependency to get the Selenium Hub Up and running
the testcases will execute on the browsers as per specificaiton from connad line or the config file.
If different browsers needs to be tested then docker hosts for that type of browser can be up and running with some script and docker file. Then the tests will run on that host with that browser parameter to Jar.
Test results will get mailed to team.
After testing is done the containers will be down.
Docker engine:
Its a client server application made up of docker deamon and REST API cli client
Docker machine:
Provision docker hosts on remote/local systems.
Supports major virtualization hypervisors.
One can use docker machine to install docker engine on multiple remote systems.
Docker swarm:
multiple docker engines is docker swarm
Docker swarm is native clustering for docker.
Docker swarm is the tool that clusters Docker hosts and schedules containers
It turns pool of docker containers into singel virtual docker host.
Docker compose:
Docker compose is different than the Dockerfile used to crete images
Kubernetes:
If you want to manage docker containers accroess vast fleet of servers and infrastruture, then you use Docker orchestration tools like Kubernetes.
Docker can not manage containers accros multiple nodes.
Its a cluster manager for docker
Kubernetes is a solution for overseeing and managing multiple containers at scale rather than just working with Docker on a manually-configured host.