Monday, August 27, 2018

Docker With Selenium WebDriver


We are now in shape to work with selenium docker containers. We need to follow the below steps

Step 1:
 We need to search docker Selenium containers to setup a distributed selenium environment, we can search it from Kitematic, cmd prompt or from Docker Hub.





We will prefer to go with Docker Hub because we get more information from this page about the searched image. We will choose the Selenium hub image from the search result which one published from SeleniumHQ.

So after clicking on details button the page will be redirected to the details page of this searched Image Details page contains the Selenium Logo those images are published from SeleniumHQ like below:






Here GitHub link is also available from where we can get more information of configuration details.
 
Step 2:
To download the latest version of Selenium/Hub image we need to type the following command in command/console
                                                    docker pull selenium/hub

Step 3:
 Give a search as “Selenium node” on Docker Hub search page. Search result should be populated as below:

We will choose Selenium/Node-firefox-Debug and Selenium/Node-Chrome-Debug. We choose this images because it is VNC enabled. We can access the GUI of this images through VNC viewer for debugging purpose of our script.

Step 4:
 To download the latest version of Selenium node images we need to type the following command in command/console

                                        docker pull selenium/node-chrome-debug
                                        docker pull selenium/node-firefox-debug

Step 5:
Now we will start selenium hub with the specific port using docker, for this, we will use the following command.

                          docker run -d -p 4446:4444 --name selenium-hub selenium/hub
 




We get the logs of this selenium/hub container using the following command
                                                     docker logs -f selenium-hub

 If we open the following machine IP/machine name/localhost/127.0.0.1:4446 page will appear as below.


Step 6:

Now we will register selenium node to selenium hub with a specific port using docker, for this, we will use the following command.




    docker run -d -p <publish port:actual port>  -p <publish port:actual port> --link <name:alias> --name <custom name> <image name>

So this will be the command to start and link the firefox node with the selenium grid

     docker run -d -p 5557:5555  -p 49339:5900 --link selenium-hub:hub --name firefox-node selenium/node-firefox-debug



We get the logs of this selenium/node-firefox-debug container using the following command
                                                     docker logs -f firefox-node




So this will be the command to start and link the firefox node with the selenium grid

docker run -d -p 5556:5555 -p 49338:5900 --link selenium-hub:hub --name chrome-node selenium/node-chrome-debug 



So if we open the console of the grid on the web browser it will look like below:




Step 7:

Download the VNC viewer as per system OS.




Using the following command, we will get the Node Firefox and Chrome IP address and Port to connect through VNC.


We need to provide the password as secret at password field to connect those machine through VNC.


After successfully connected this screen should be available.


Note : 

  • We can configure a node with multiple browser using the following command but it is not recomended.

docker run -d -p 5557:5555 -p 49339:5900 -e NODE_MAX_INSTANCES=5 -e NODE_MAX_SESSION=5 --link selenium-hub:hub --name firefox-node selenium/node-firefox-debug

docker run -d -p 5556:5555 -p 49338:5900 -e NODE_MAX_INSTANCES=5 -e NODE_MAX_SESSION=5 --link selenium-hub:hub --name chrome-node selenium/node-chrome-debug

  • Tagging convention for images is like below:

    <Major>.<Minor>.<Patch>-<Chemical Element in Alphabetical order> 
We can follow the below commands for docker network

  •  docker network create <NETWORK_NAME>
  •  docker run -d -p <grid host port:grid docker port> --net grid --name selenium-hub selenium/hub
  •  docker run -d -p <node host port:node docker port> -p <vnc host port:vncdocker port> --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-chrome-debug
  •  docker run -d -p <node host port:node docker port> -p <vnc host port:vncdocker port> --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-firefox-debug


 

Saturday, August 25, 2018

Handling Docker With UI Kitematic-Windows

On our previous post, we have learned how to install and use docker using the command line. Here we will learn how to handle docker from UI.

Step 1: 

Right Click on Docker icon from the system tray and click on the Kitematic option.

Step 2:

Download option should be available then click on download button.

 Step 3 :

After completion of the download extract the folder. After the extraction folder it looks like below.

Step 4 :

Kitematic login window will appear we can skip it.

 After login or Skipping this window Kitematic window will be appear like below.

 Step 5 :

Search for the required images.



Step 6: 

Click on Create button, it will download the latest image and run.

 Step 7 : 

To download and run any particular version of an image we need to click on the ellipsoid icon which is beside the Create button.


Now click on Selected Tag option.


Now select the tag as per our requirement, highlighted tag name denotes the default tag version.

 Step 8 :

 We can get the settings of any containers from Settings tab of the any perticular container.


General Tab:

We can change the settings like name, environment variables details etc from the General tab
 Hostname / Ports:

 Port, and network related things can be handled from Hostname/Ports tab. We can publish port from this tab for communite or access this container from external environments.
Volumes:
 Network:
  Network setting of containers and links with the different container is possible from this tab.
 Linking is a important thing by which we can make sure that different containers can communicate.

 Advanced:




Monday, August 20, 2018

Docker Installation And Some Commands

Everyday technology is evolving and we are implementing or better to say find out the way more stable, easy and hardware to the software-centric solution.

So Docker is one of the most popular solutions for that. Previously we are habituated to use virtual machines but nowadays we are more focused on Dockerization. In Docker we get some extra facility over VM, key-points are discussed below :


As per the diagrammatic difference, we say that in every VM's have an own OS or we can say need a guest OS but in Docker, we don't need any guest OS Docker to use the host OS kernel in read-only mode so it's lighter. Docker Demon service plays the role in the background to communicate with the kernel, resource sharing and many more things in the background. Here one thing we need to know Docker CE for Windows provides development environments for both Linux and Windows Containers. The Linux Docker host on Windows is based on a Hyper-V VM

So let's start to install and configure the Docker in Windows 10 machine.

Step 1 : 
 We can find two types of Docker installer.
  • Docker Community Edition (CE)
  • Docker Enterprise Edition (EE)


Here we will use CE for Windows. So we need to download the Docker agent for Windows, in this discussion we are using Windows 10.


Here we need to keep in mind
  • Need Hyper-V enabled.
  • Virtualization must be enabled from BIOS.
  • Windows 10 version should be 64bit Windows 10 Pro, Enterprise and Education (1607 Anniversary Update, Build 14393 or later)
Step 2 :
Click on Download From Docker Store Button.and then click on Please Login To download button from next page.

 For downloading the Windows Docker agent need to have docker account after providing the login details we need to click the Get Docker button from the next page,

If we don't have the docker account we need to create that one from Create Account link from the login page.




Step 3: 
 Just install the Docker agent with default settings. After installation successfully completed and restarted the machine we can find a white color whale(the whale’s name is “Moby Dock) bearing a pile of shipping containers in the system tray.

If Docker is not able to start successfully it will available as a red color whale in the system tray.


 Step 4 : 
 Now we are in shape to discuss some mostly used docker commands.

  • docker info  
           This command gives us the docker info like running paused or stopped containers, images etc.


  • docker version
            This command gives us the docker version details

  • docker images
            This command gives us the downloaded image details

  • docker pull <image name> 
            This command used to download the images

We can also pass the tag name when we pull any particular version of image else it will download the latest one.
The command looks like docker pull <image name>: tag-name
  • docker run <image name>
            This command used to run the container
 We can also pass the tag name when we run any particular version of image else it will run the latest one.
The command looks like docker run<image name>: tag-name
  • docker run --name <custom name> <image name>
             This command helps us to run a container with a meaningful name.
  • docker run -t -i <image name>
             This command is used to run the container in interactive mode. Here -t parameter represents terminal and -i parameter represents interactive mode.

  • docker run -d <image name> 
                 This command is used to run a image in demon or detached mode.
     
  • docker run -P <image name> 
             This command is used to publish a port to communicate with container and it will assign a dynamic port.
  • docker run -p mappingport:port <image name> 
             This command is used to publish a specific port to communicate with container.
  • docker run --link <linking container name> :<alias>  <container imagename>
                  This command is required to communicate with different containers.

  • docker container ls -a
            This command gives us the containers details


  • docker ps -a
            This command gives us the containers details



  • docker stop <container name or container id>
             This command used to stop the container

  • docker container stop <container name or container id
            This command used to stop the container

  • docker rm <container name or container id
            This command used to remove the container

  • docker container rm <container name or container id
            This command used to remove the container

  • docker rmi <imagename>  
             This command used to delete the image

  • docker rmi  -f <imagename>  
             This command used to delete image forcefully

  • docker logs <container name or container id>
             This command used to show the logs for a particular container.

  • docker search <image name>
               This command is useful to find out any perticular image from Docker hub repository.


  •  docker inspect <container name or container id>
              This command is useful to get all the container configuration details.