Docker Installation In Windows System Through Oracle Virtual Box

Currently, we can’t install docker in our windows system due to some technical challenges. Then how can we proceed with some demo/poc for the docker image?

These can be handled by creating a Linux virtual machine through Oracle virtual box. Here we go for the steps of installation.

  1. Install Oracle virtual Box Downloads - Oracle VM VirtualBox
  2. Download Alpine - Linux distribution downloads | Alpine Linux
  3. Why Alpine Linux Distribution? - Small. Simple. Secure. Alpine Linux is a security-oriented, lightweight Linux distribution.
  4. In the Installed oracle virtual box, click on New and Give name, select Type as Linux and version as Linux 2.6

  5. Choose the memory size for your virtual machine

  6.  All other options like Hard disk, hard disk file type, memory allocation be the default options.

  7. As soon as it is created, click on the settings from oracle virtual box

  8. Click on storage and select the image ( alpine image which we downloaded in step 2)

  9. Now let's start the machine

  10. It will ask for start up disk to select, let's select the alpine image.

  11. Now, it will start booting. it will ask for the login. Give as ‘root’. It doesn’t have a password.

  12. To start the alpine setup, need to give the following command ‘setup-alpine

  13. It will ask a few things to choose like keyboard setup, date, and time setup .*For anything default values, just give enter

    • Enter keyboard setup as ‘us’ and variant as ‘us

    • Enter system hostname as ‘localhost

    • For initialize IP address, manual configuration, give default values.

    • It will ask to setup a new password.

    • Select the time zone. By default it is UTC. To know the list of time and sub time zone, give? and then select values from that

    • for proxy URL, NTP Client, mirror number, SSH server give default values(just give enter)

    • For the hard disk, we have chosen SDA in step 4, so give sda

    • for how to use hard disk. enter sys.

    • Now it will start installing the complete packages. It will ask to erase the disk, enter y.
      It will take 1 to 5 mins for the installation. After installation, reboot it. To reboot just enter poweroff from the command line

  14. If you want to access the VM from outside( from my host system) through mobaxterm, putty or some other SSH client, etc, we need to change the network settings. So click on settings from Oracle virtual box and click on Network and select Bridged Adapter

  15. And also remove the floppy and optical from the system, because we already installed OS on our hard drive

  16. Now let's start the system. Now, this is the actual IP of the virtual machine 192.168.1.12

  17. Login as root and type the password

  18. To Access these machine from host system, we need to do one more thing. open sshd config file like these vi /etc/ssh/sshd_config from command line

    • Find these line ‘Permit RootLogin ‘. Remove the hash and remove prohibit-password and give yes. To edit values, first enter the key “i”

    • And then save it using esc key, and with the help of the command :wq

    • Now restart the sshd using the following command service sshd restart

       

  19. Now let's try to access these virtual machines from my host system through any of the ssh client. Here I am using git bash. Already I noted my IP address from step 16 as 192.168.1.12

    • Enter ssh root@ip

    • It will prompt for pwd

    • Give command vi /etc/apk/repositories

    • You can able to see a couple of repositories commented out there, uncomment it by removing the hash and save it.

    • To edit, enter key “i”

    • To save enter Esc key and then :wq command

  20. Now to install docker, just enter the following command apk add docker

  21. Docker is installed successfully now and to start the docker service, just type the following command service docker start


    Now let's check the docker with the help of the following commands like docker images

  22. To check the docker, star the nginx server using the following command
    docker run -p 8989:80 -d nginx
    It pulled the image and docker image is running successfully in the virtual machine. To test it, browse the IP address (http://192.168.1.12/) from your local machine, with the port we have exposed. so it is http://192.168.1.12/8989/




Docker is Up and running now !!!! :) Now you can start playing with your docker with these virtual machines.