Thursday, July 25, 2019

[DOCKER] Setting up docker in a CentOS VM on Hyper V




1. Download CentOS image

2. Follow steps here to install CentOS ( https://www.google.com/search?q=install+centos+on+hyper-v&rlz=1C1GCEB_enDE854DE854&oq=install+centos+on+hyper&aqs=chrome.0.0j69i57j0l4.3911j0j9&sourceid=chrome&ie=UTF-8 )

  1. Download CentOS ISO from 
    https://www.centos.org/download/
  2. In Hyper-V Manager select New / Virtual Machine…
  3. Click Next on the Before You Begin page
  4. Enter Name
  5. Click Next
  6. Select Generation 1 If you don't you will not be able to mount the ISO for Cent-OS
  7. Click Next
  8. Enter 512
  9. Click Next
  10. Connect to the same external network with internet access used for your Windows VM
  11. Click Next
  12. Select Create a virtual hard disk
  13. Click Next
  14. Select Install an operating system from bootable CD/DVD-ROM
  15. Select Image file (.iso)
  16. Browse to CentOS iso.
  17. Click Next
  18. Click Finish
With the VM created it is now time to install the OS.
  1. Right-Click VM
  2. Select Start 
    image
  3. Double-click VM
  4. Select Install CentOS 7
  5. Press Enter
  6. Select English / English (United States)
  7. Click Continue
  8. Click Installation Destination 
    image
  9. Click Done
  10. Click Network & Host Name
  11. Make sure that you choose to have the full installation with GNOME option
  12. Click toggle to turn on 
    image
  13. Click Done
  14. Click Begin Installation
  15. Click Root Password
  16. Enter Root Password
  17. Enter Confirm
  18. Click Done
  19. Click User Creation
  20. Enter Full name
  21. Enter User name
  22. Check Make this user administrator
  23. Enter Password
  24. Enter Confirm password
  25. Click Done
  26. Click Reboot 
    image
Your server is now installed and ready for use.
To connect the VM to the internet
1. Click start
2. Hyper V manager
3. Actions -> Virtual Switch Manager 
4. Highlight external -> Create Virtual Switch
5. Give it a name
6. Highlight external network -> choose the network adapter

In the VM 
1. Click File-> Settings
2. Go to Network Adapter tab
3. Choose the Virtual switch created
4. Make sure "Enable virtual LAN" is unchecked
5. In the VM go to settings and choose wired connection

Install Docker
reference

Uninstall old versions

Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.
$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
It’s OK if yum reports that none of these packages are installed.
  1. Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapperstorage driver.
    $ sudo yum install -y yum-utils \
      device-mapper-persistent-data \
      lvm2
    
  2. Use the following command to set up the stable repository.
    $ sudo yum-config-manager \
        --add-repo \
        https://download.docker.com/linux/centos/docker-ce.repo
    

INSTALL DOCKER ENGINE - COMMUNITY

  1. Install the latest version of Docker Engine - Community and containerd, or go to the next step to install a specific version:
    $ sudo yum install docker-ce docker-ce-cli containerd.io
    
    If prompted to accept the GPG key, verify that the fingerprint matches060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it.

  1. Start Docker.
    $ sudo systemctl start docker
    
  2. Verify that Docker Engine - Community is installed correctly by running the hello-world image.
    $ sudo docker run hello-world


To add current user to avoid sudo each time docker runs

sudo usermod -aG docker $USER



Configure Docker to start on boot

Most current Linux distributions (RHEL, CentOS, Fedora, Ubuntu 16.04 and higher) use systemd to manage which services start when the system boots. Ubuntu 14.10 and below use upstart.

systemd

$ sudo systemctl enable docker
To disable this behavior, use disable instead.
$ sudo systemctl disable docker







Start manually

Once Docker is installed, you need to start the Docker daemon. Most Linux distributions use systemctl to start services. If you do not have systemctl, use the servicecommand.
  • systemctl:
    $ sudo systemctl start docker
    
  • service:
    $ sudo service docker start



No comments:

Post a Comment

Loud fan of desktop

 Upon restart the fan of the desktop got loud again. I cleaned the desktop from the dust but it was still loud (Lower than the first sound) ...