Running your own private docker registry service

I’m talking about a service like docker hub for your organization. This can be achieved by using docker’s registry image. I assume that you have docker running on your host.Let’s dive deep into its implementation.

Pull the registry image from docker hub

docker pull registry

Docker’s private registry image serves on port 5000. So we will forward to port 5000 on host.

docker run -d -p 5000:5000 –name dilipregistry registry

Lets pull an image locally and then push it to your docker registry

docker pull ubuntu

Tag the image like <registry_server_ip>:<port>/<name_of_image>

 docker tag ubuntu localhost:5000/ubuntu

push it to your docker registry

 docker push localhost:5000/ubuntu

You can search for the image which you just pushed to private registry.

 docker images localhost:5000

docker stop registry && docker rm -v registry

By default, your registry container uses a docker volume on the host filesystem.

Specifically, you might want to point your volume location to a specific place in order to more easily access your registry data. To do so you can:

docker run -d -p 5000:5000 –restart=always –name registry \
-v `pwd`/data:/var/lib/registry \
registry:2

For wider adoption of your docker private registry over the network you need to give TLS certs to docker daemon.

creating self-signed TLS certificates 

mkdir -p certs

openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -x509 -days 365 -out certs/domain.crt

Make sure you stopped your registry from the previous steps, then start your registry again with TLS enabled:

 docker run -d -p 5000:5000 –restart=always –name registry \
-v `pwd`/certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
registry:2

You should now be able to access your registry from another docker host:

 docker pull ubuntu
docker tag ubuntu <registry_server_ip>:5000/ubuntu
docker push <resistry_server_ip>:5000/ubuntu
docker pull <registry_server_ip>:5000/ubuntu

Reference: docker documentation

Feel free to comment and always open for advises.

 

Advertisements

Libvirt with support for VMware ESXi

By default  ubuntu 14.04 LTS, libvirt package doesn’t support VMware ESXi. By making some tweaks to libvirt’s debian source you can have working libvirt which supports ESXi along with the trivial ones.

mkdir libvirt
cd libvirt
apt-get source -d libvirt
sudo apt-get build-dep libvirt fakeroot
dpkg-source -x libvirt*dsc
nano libvirt*/debian/rules
        Change "--without-esx" to "--with-esx"
        Change "--without-libssh2" to "--with-libssh2"
cd libvirt*
sudo apt-get install libcurl4-gnutls-dev
dpkg-buildpackage -us -uc -b -rfakeroot
cd ..
sudo dpkg -i *.deb

MAAS on VMware ESXi

After being gone through a lot of difficulties in successfully configuring Cannonicals MAAS server to use VMware ESX power type, i thought it is worth writing the solution which i found. Follow the steps below

  1. Install VMware ESXi on a Bare metal server and create a virtual machine for MAAS  with 2 Nics in which one is attached to External Provider Network(for internet connectivity) and the other is for MAAS vms Network.
  2. Give a static ip on 2nd Nic and configure the network through MAAS GUI.
  3. Now Create virtual machines(with pxe boot enabled)  with 2 Nics one is attached to External Provider Network and the other to MAAS Network.
  4. Turn on the newly created virtual machines, so they will be appeared on MAAS UI with a random name given by MAAS server.
  5. Install libvirt-bin with ESXi enabled on MAAS server by following instructions given in my github repository https://github.com/DilipRenkila/libvirt-esxi
  6. Power Configuration.

maas

  • power type : virsh (Virtual systems)
  • power address : esx://root@142.4.219.161?no_verify=1
  • power id : name of virtual machine
  • password : esxi root password (necessary)

Devstack with LXD

Everybody wanna try amazing technology lxd with Openstack but i agree that there is no detail guide to it. So i decided to share my experience.

1) First install stable ppa of lxd

sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install lxd

2) Create a newgroup called lxd

newgrp lxd

3) For good performance it better to have /var/lib/lxd on lvm (or) zfs.I reccommend to use LVM as this is a basic installation.

sudo init lxd

4) Clone the devstack repository in /opt/stack directory

git clone https://git.openstack.org/openstack-dev/devstack /opt/stack/devstack

5) Create a file named local.conf in /opt/stack/devstack directory and copy the following

[[local|localrc]]
enable_plugin nova-lxd https://github.com/lxc/nova-lxd

6) run stack.sh

./stack.sh 

7) If you encounter any issues try by commenting out all lines in /opt/stack/nova-lxd/test-requirements.txt

sudo nano /opt/stack/nova-lxd/test-requirements.txt
## check whether the requirements in that file are met (or) not

8) run unstack.sh

./unstack.sh

9) Then Retry with stack.sh

./stack.sh

10) In Devstack try uploading root.tar.gz images with disk format as RAW.