Docker Cookbook


CI/CD: Setting Up a Development Environment | 303



Download 6,31 Mb.
Pdf ko'rish
bet236/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   232   233   234   235   236   237   238   239   ...   260
Bog'liq
Docker Cookbook

10.1 CI/CD: Setting Up a Development Environment | 303


deployed together with the rest of the application containers by using 
docker-
compose
.
10.2 CI/CD: Building a Continuous Delivery Pipeline with
Jenkins and Apache Mesos
Contributed by Pini Reznik
Problem
You would like to set up a continuous delivery pipeline for an application packaged
using Docker containers.
Solution
Set up a Jenkins continuous integration server to deploy an application to a Mesos
cluster in case the tests are passing.
Figure 10-1
gives a graphical representation of the environment you are going to use
at the end of this recipe. The goal is to take an application from a development envi‐
ronment, package it into a Docker container, push it to the Docker registry in case the
tests are passing, and tell Marathon to schedule the application on Mesos.
Figure 10-1. Continuous delivery pipeline using Jenkins and Apache Mesos
This recipe uses the previous example in 
Recipe 10.1
. You can also see a way to set up
a Mesos cluster for development purposes in 
Recipe 7.2
.
304 | Chapter 10: Application Use Cases


First you need to set up a Jenkins server. The easiest way is to use the following
Docker Compose configuration:
jenkins:
image: jenkins
volumes:
- jenkins-home:/var/jenkins_home
ports:

"8080:8080"
The volumes defined in the preceding Compose file act as persistent storage to avoid
losing your build configurations and data every time you restart your Jenkins con‐
tainer. It is the responsibility of the owner to back up and maintain those folders out‐
side Docker containers.
Start Docker Compose with the following command:
$ docker-compose up
You get a functional Jenkins server running on the following address: 
http://localhost:
8080
.
This was an easy task, but unfortunately not useful because you need to build an
image that includes your application and also need to start containers using the newly
built image to test your application. This is not possible in a standard Docker con‐
tainer.
To solve this, you can add two more lines to 
docker-compose.yml
:
jenkins:
image: jenkins
volumes:
- jenkins-home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
ports:

"8080:8080"
Two new volumes will mount the socket used for the communication between
Docker client and server and add the Docker binary itself to act as a client. This way,
you can run Docker commands inside the Jenkins container, and they will be exe‐
cuted on the host in parallel to the Jenkins container itself.
Another hurdle on the way toward a fully functional Jenkins server capable of run‐
ning Docker commands is permissions. By default, 
/var/run/docker.sock
is accessible
to 
root
or anyone in the group called 
docker
. The default Jenkins container is using a
user called 
jenkins
to start the server. The Jenkins server does not belong to the
docker
group, but even if it was in such a group inside the container, it still would not
get the access to the Docker socket, as groups’ and users’ IDs differ between the host

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   232   233   234   235   236   237   238   239   ...   260




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish