Saturday 4 February 2017

Quick start for Docker under proxy [POC/Learning purpose only]


Installation on Windows:


Preparation:
To get started you have to enable virtualization from your computer.
Start your computer and press ESC that will give you options to choose. In my case F10 key is responsible for BIOS setting. Go to system setting (Under Advanced section) and enable the virtualization setting and you are good to go.

Installation:
Installation is very straight forward. The easiest way to install Docker is to go to their website and follow the installation instructions for your Operating System.  
In my case I want install docker in my windows 7 machine so docker toll box needs to be installed. Refer the url here for docker toolbox https://www.docker.com/products/docker-toolbox

After Installation
Once you install docker you will see below Icons in you desktop





Click on Docker Quick start to get started.
Interesting part is that to make docker work under proxy you need to do some tweaks. After installation if you run the below command for testing docker, it will not work –
docker run hello-world
In my case I have not used the default docker machine. I have created one new docker machine with the below command –

docker-machine create -d virtualbox     --engine-env HTTP_PROXY=http://<your_proxy>:<port>     --engine-env HTTPS_PROXY=https://<your_proxy>:<port>  --engine-env NO_PROXY= localhost,127.0.0.1,<machine_ip>  test1


Above command will create the docker machine named test1 for you.

Once you execute the command you will see line like below

“Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this vi
rtual machine, run: C:\Program Files\Docker Toolbox\docker-machine.exe env test1

Then execute the below commands-
docker-machine ls
docker-machine env test1

then execute the eval command
eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env test1)


Then you can test the command –
docker run hello-world

This should work now….

Installation on Centos 7


Prerequisites:
Docker requires a 64-bit OS and version 3.10 or higher of the Linux kernel.
Check using below command
uname -r
Installation
Install with yum… first update all the packages using below command..
sudo yum update
Install the
sudo yum install docker-engine
sudo systemctl enable docker.service
sudo systemctl start docker

After Installation:
Create directory:
mkdir /etc/systemd/system/docker.service.d
Create one file called http-proxy.conf under /etc/systemd/system/docker.service.d



Content of the file is like below
[Service]
Environment="HTTP_PROXY=http://<username>:<password>@<proxy_name>:<proxy_port>/" "HTTP_PROXY=http:// <username>:<password>@<proxy_name>:<proxy_port>/" "NO_PROXY=localhost,127.0.0.1,<machine_ip>"

Upload the changes:
sudo systemctl daemon-reload

Restart the docker service
sudo systemctl restart docker

Now you are good to go. Go ahead to check the below command
sudo docker run hello-world


Hope this will be helpful... :-)


Note: Blogs which I have written are totally my personal view based on my personal experience.


Make life easier — Git automation with single command file

Make life easier — Git automation with single command file Posted on medium #makelifeeasier series - Automation of git related activity...