forked from khadarbasha019/dockermsproject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPROCESS
More file actions
167 lines (131 loc) · 4.43 KB
/
PROCESS
File metadata and controls
167 lines (131 loc) · 4.43 KB
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
DOCKER PROJECT:
yum install docker -y
systemctl start docker
systemctl status docker
FROM ubuntu
RUN apt-get update -y
RUN apt-get install apache2 -y
COPY index.html /var/www/html/
CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
DOCKER FILE : To create image by automation.
DOCKER COMPOSE : To create multiple containers on single server.
DOCKER SWARM : To create multiple containers on Multiple server.
DOCKE STACK : Docker swarm + Docker compose
1. CREATE 3 SERVERS AND INSTALL DOCKER ON ALL OF THEM & CREATE CLUSTER OF IT
yum install docker -y
systemctl start docker
systemctl status docker
docker swarm init --advertise-addr 172.31.85.110
docker node ls
2. INSTALLING JENKINS (MASTER)
#STEP-1: INSTALLING GIT JAVA-1.8.0 MAVEN
yum install git java-1.8.0-openjdk maven -y
#STEP-2: GETTING THE REPO (jenkins.io --> download -- > redhat)
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
#STEP-3: DOWNLOAD JAVA11 AND JENKINS
amazon-linux-extras install java-openjdk11 -y
yum install jenkins -y
update-alternatives --config java
#STEP-4: RESTARTING JENKINS (when we download service it will on stopped state)
systemctl start jenkins.service
systemctl status jenkins.service
3. CREATE CUSTOM IMAGES AND PUSH TO DOCKERHUB WITH TAGS
DOCKER FILE:
FROM ubuntu
RUN apt-get update -y
RUN apt-get install apache2 -y
COPY index.html /var/www/html/
CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
INDEX.HTML:
PIPELINE:
pipeline {
agent any
stages {
stage('checkout') {
steps {
git 'https://github.com/RAHAMSHAIK007/dockernewproject.git'
}
}
stage('build') {
steps {
sh 'docker build -t $img .'
}
}
stage('tag') {
steps {
sh 'docker tag $img $repo'
}
}
stage('push') {
steps {
sh 'docker login -u -p '
sh 'docker push $repo'
}
}
}
}
4. GIVE PERMISSIONS
chmod 777 /var/run/docker.sock
systemctl daemon-reload
systemctl restart docker.service
5. WRITE COMPOSE FILE AND PUSH TO GITHUB
version: '3'
services:
devops:
image: rahamshaik/devopsreponit:latest
ports:
- "80:80"
volumes:
- "devopsvol"
deploy:
replicas: 3
aws:
image: rahamshaik/awsreponit:latest
ports:
- "81:80"
volumes:
- "awsvol"
deploy:
replicas: 3
datascience:
image: rahamshaik/datasciencereponit:latest
ports:
- "82:80"
volumes:
- "datasciencevol"
deploy:
replicas: 3
azure:
image: rahamshaik/azurereponit:latest
ports:
- "83:80"
volumes:
- "azurevol"
deploy:
replicas: 3
DOCKER STACK:
Docker stack is used to create multiple services on multiple hosts. i.e it will create multiple containers on multile servers with the help of compose file.
To use the docker stack we have initialized docker swarm, if we are not using docker swarm, docker stack will not work.
once we remove the stack automatically all the containers will gets deleted.
We can share the containers from manager to worker according to the replicas
Ex: Lets assume if we have 2 servers which is manager and worker, if we deployed a stack with 4 replicas. 2 are present in manager and 2 are present in worker.
Here manager will divide the work based on the load on a server
COMMAND:
TO DEPLOY : docker stack deploy --compose-file docker-compose.yml stack_name
TO LIST : docker stack ls
TO GET CONTAINERS OF A STACK : docker stack ps stack_name
TO GET SERVICES OF A STACK: docker stack services stack_name
TO DELETE A STACK: docker stack rm stack_name
PORTAINER:
it is a container organizer, designed to make tasks easier, whether they are clustered or not.
abel to connect multiple clusters, access the containers, migrate stacks between clusters
it is not a testing environment mainly used for production routines in large companies.
Portainer consists of two elements, the Portainer Server and the Portainer Agent.
Both elements run as lightweight Docker containers on a Docker engine
SETUP:
Must have swarm mode and all ports enable with docker engine
curl -L https://downloads.portainer.io/ce2-16/portainer-agent-stack.yml -o portainer-agent-stack.yml
docker stack deploy -c portainer-agent-stack.yml portainer
docker ps
public-ip of swamr master:9000