• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How Setup Private Docker Registry on Ubuntu 16.04 LTS Cloud Server

By Abhishek Ghosh January 6, 2018 7:05 am Updated on April 25, 2018

How Setup Private Docker Registry on Ubuntu 16.04 LTS Cloud Server

Advertisement

In series of our previously published guides on Docker, we discussed around using Docker. In those guides we used Docker’s public repository to pull, push Docker images. We discussed about limitations of Docker Community Edition too. You Can Have Your Own Docker Registry on Own Cloud Server Instance with limitations of Docker Community Edition. Here is How Setup Private Docker Registry on Ubuntu 16.04 LTS Cloud Server. Here is official guide around registry :

Vim
1
2
https://docs.docker.com/registry/
https://github.com/docker/docker-registry

On that webpage, you’ll notice they talked about “Docker Trusted Registry (DTR)”, that is not available on Docker Community Edition. We have full command line.

 

How Setup Private Docker Registry on Ubuntu 16.04 LTS Cloud Server

 

Obviously, you’ll need have Docker installed on that machine. You can follow our first guide on Docker in case you are not used with Docker. Next, we need a web server software installed on that machine. We can run that web server in two ways. First way is installing on main server, which is less commonly done. You can follow our old guides to install Apache2 on Ubuntu 16.04. If you want Nginx, then follow guide to install Nginx on Ubuntu 16.04 (install only Nginx).
Second way is running a Nginx container inside Docker and linking it.

Advertisement

---

How Setup Private Docker Registry on Ubuntu 16.04 LTS Cloud Server

Now the practical running command part. We need some directories to be present :

Vim
1
2
3
4
5
mkdir /docker-registry
mkdir  /docker-registry/data
mkdir /docker-registry/nginx
chown root:root /docker-registry
cd /docker-registry

We need Docker-Compose, Apache utilities and curl :

Vim
1
2
apt-get -y install python-pip
apt-get install -y docker-compose apache2-utils curl

we can pull the Docker Registry image :

Vim
1
sudo docker pull registry:latest

and run it :

Vim
1
sudo docker pull registry:latest

Go to /Docker-Registry/Data :

Vim
1
2
cd ..
cd /Docker-Regisry/Data

Open :

Vim
1
nano docker-compose.yml

Content should look like this :

Vim
1
2
3
4
5
6
7
8
registry:
      image: registry:2
      ports:
        - 127.0.0.1:5000:5000
      environment:
        REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /Data
      volumes:
        - ./Data:/Data

Change 127.0.0.1 with your machine’s IP address. Save and close the file.

Vim
1
2
3
cd ..
cd /Docker-Registry
sudo docker-compose up

Press CTRL-C to shut down your Docker registry container. Run :

Vim
1
2
mkdir /Docker-Registry/nginx
nano /Docker-Registry/docker-compose.yml

Add the following content into the top of the file:

Vim
1
2
3
4
5
6
7
8
    nginx:
      image: "nginx:1.9"
      ports:
        - 5043:443
      links:
        - registry:registry
      volumes:
        - ./nginx/:/etc/nginx/conf.d:ro

Save and close the file. create a new Nginx configuration file.

Vim
1
nano /Docker-Registry/nginx/registry.conf

Add the following content:

Vim
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
    upstream docker-registry {
      server registry:5000;
    }server {
      listen 443;
      server_name yourdomain.com;# SSL
      # ssl on;
      # ssl_certificate /etc/nginx/conf.d/domain.crt;
      # ssl_certificate_key /etc/nginx/conf.d/domain.key;# disable any limits to avoid HTTP 413 for large image uploads
      client_max_body_size 0;# required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486)
      chunked_transfer_encoding on;location /v2/ {
        # Do not allow connections from docker 1.5 and earlier
        # docker pre-1.6.0 did not properly set the user agent on ping, catch "Go *" user agents
        if ($http_user_agent ~ "^(docker/1.(3|4|5(?!.[0-9]-dev))|Go ).*$" ) {
          return 404;
        }# To add basic authentication to v2 use auth_basic setting plus add_header
        # auth_basic "registry.localhost";
        # auth_basic_user_file /etc/nginx/conf.d/registry.password;
        # add_header 'Docker-Distribution-Api-Version' 'registry/2.0' always;proxy_pass                          http://docker-registry;
        proxy_set_header  Host              $http_host;   # required for docker client's sake
        proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP
        proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header  X-Forwarded-Proto $scheme;
        proxy_read_timeout                  900;
      }
    }

Save and close the file. Run :

Vim
1
2
3
cd /Docker-Registry
# pwd
sudo docker-compose up

Two containers should be running.

We need a username-password based authentication method for Nginx frontend :

Vim
1
2
cd /Docker-Registry/nginx
sudo htpasswd -c registry.password USERNAME

Now open the registry file :

Vim
1
nano /Docker-Registry/nginx/registry.conf

You need these lines to be active :

Vim
1
2
3
    auth_basic "registry.localhost";
    auth_basic_user_file /etc/nginx/conf.d/registry.password;
    add_header 'Docker-Distribution-Api-Version' 'registry/2.0' always;

Save and close the file. Test :

Vim
1
2
3
cd /Docker-Registry
sudo docker-compose up
curl http://localhost:5043/v2/

On /Docker-Registry/nginx/registry.conf, you’ll notice these lines :

Vim
1
2
3
    ssl on;
    ssl_certificate /etc/nginx/conf.d/domain.crt;
    ssl_certificate_key /etc/nginx/conf.d/domain.key;

Those are intended to active to have full SSL support. You know how to obtain Let’s Encrypt SSL certificate on Ubuntu 16.04 for domain.

Basic steps for self-signed certificate is like below :

Vim
1
2
3
4
5
6
7
cd /Docker-Registry/nginx
openssl genrsa -out CA.key 2048
openssl req -x509 -new -nodes -key CA.key -days 10000 -out CA.crt
openssl genrsa -out domain.key 2048
openssl req -new -key domain.key -out CA.csr
openssl x509 -req -in CA.csr -CA CA.crt -CAkey CA.key -CAcreateserial -out domain.crt -days 10000
sudo cp CA.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates

Obviously, adjust Nginx settings. You have to restart Docker :

Vim
1
sudo service docker restart

You can copy CA.crt file from registry server to client machine by running the command :

Vim
1
2
sudo scp /Docker-Registry/nginx/CA.crt root@client-machine:/usr/local/share/ca-certificates/
sudo service docker restart

From client computer, if you run :

Vim
1
sudo docker login https://YOUR-DOMAIN:5043

You’ll get expected output. Rest are written on Github’s that official repository’s documentation.

This Article Has Been Shared 567 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How Setup Private Docker Registry on Ubuntu 16.04 LTS Cloud Server

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Steps To Install Nginx Plus on Ubuntu Server (HP Cloud)

    Here Are the Steps To Install Nginx Plus on Ubuntu Server Running on HP Cloud. Nginx Plus is the Paid Version of Nginx with Extra Features.

  • Navigating the Benefits of Docker Registry

    Docker Registry is a collection of repositories with indexes, access control rules. API is used by the clients to obtain images from repos.

  • WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud

    Here is a Step by Step Guide on Setting Up WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud with All Commands and the Configuration.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us
Page Visits Alerts

Recent Posts

  • How To Install Apache NiFi On Ubuntu 22.04 LTSMay 28, 2023
  • What is the Difference Between Apache License 2.0 and GNU GPL 3.0May 27, 2023
  • Top Slot Software for Online CasinosMay 26, 2023
  • What is an Integrated Development Environment (IDE)May 26, 2023
  • List of Android Smartphones with a Stylus in 2023May 25, 2023

About This Article

Cite this article as: Abhishek Ghosh, "How Setup Private Docker Registry on Ubuntu 16.04 LTS Cloud Server," in The Customize Windows, January 6, 2018, May 28, 2023, https://thecustomizewindows.com/2018/01/setup-private-docker-registry-ubuntu-16-04-lts-cloud-server/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT