Setting up Docker Private Registry

create a folder which name is docker-private-registry

then install docker compose

pip install docker-compose

then create the docker-compose.yml

registry:
image: registry
environment:
– STORAGE_PATH=/registry
volumes:
– registry-stuff:/registry
ports:
– “5000:5000”

run the compose file with

docker-compose up

then you will see the blank page when you visit http://localhost:5000

private registry is done but i found the nice ui for registry

 

How To Dockerize Jenkins

create a sample directory  with mkdir jenkinsci and create a new Dockerfile

cd jenkinsci

touch Dockerfile

 

FROM jenkins:2.0

USER root
RUN apt-get update \
&& apt-get install -y sudo \
&& rm -rf /var/lib/apt/lists/*
RUN echo “jenkins ALL=NOPASSWD: ALL” >> /etc/sudoers

USER jenkins
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt

then create a plugins.txt file for jenkins plugins

scm-api:latest
git-client:latest
git:latest
greenballs:latest

save it then build the jenkins image

sudo docker build -t jenkinsci .

now we must to run container

sudo docker run -d -v /var/run/docker.sock:/var/run/docker.sock \
-v $(which docker):/usr/bin/docker -p 8080:8080 jenkinsci

by the way we mapped docker socket ,binary  for running docker commands in container

this command will return container job id. Dont clear the console!

when you visit the http://localhost:8080 you will see the jenkins default login screen

 

you can find the administator password with

docker logs <job_id>

———————————————————————————————————————-

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

67120601cc394ff697b8a23e30440288


You can continue the next steps then you will see the Jenkins Home screen, then we must the test docker command with docker-test project

  • Create a Freestyle Project
  • Add shell build step then save it
  • sudo docker run hello-world

  • Run the build and look at the build logs

run the build.

 

Well, you dockerized jenkins 🙂 awesome!  In next chapter we will integrate jenkins volume

 

 

Chef – 07– Cookbooks

#you can generate the cookbook with this command
chef generate cookbook learn_chef_apache2

#run the ‘tree’ command. if you dont have a tree package you can install with apt-get install tree
#then

chef generate template learn_chef_apache2 index.html
#it will create a template file index.html.erb in templates folder

# then we must edit the default.rb recipe

sudo nano learn_chef_apache2/recipes/default.rb

package ‘apache2’

service ‘apache2’ do
action [ :enable, :start]
end

template ‘/var/www/html/index.html’ do
source ‘index.html.erb’
end

#then run the command
chef-client –local-mode –runlist ‘recipe[learn_chef_apache2]’

# change the erb file and re run the chef cookboks then run curl localhost you will see the changes

#you can upload your cookbook to chef server

knife upload cookbook learn_chef_apache2

https://github.com/apocoder/devops/blob/master/chef/chapter_1/03_cookbooks.sh