Sunday 17 July 2022

How to Connect to a Remote Docker Daemon ?

 

Check post for MAVEN commands and Interview Question:
MAVEN Commands

Docker Commands:Interview Question

Pre-Requisite: 

Docker architecture

Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers. 

The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. 

The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface. Another Docker client is Docker Compose, that lets you work with applications consisting of a set of containers.



The Docker daemon

The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.

****************
==> How to create DOCKER IMAGE from SCRATCH <==
****************

Pre-Requisite:

  • A Ubuntu 18.04 installed on one of VM instance
  • Install Docker

Create the directory to store the configuration file.

sudo mkdir -p /etc/systemd/system/docker.service.d

Create a new file to store the daemon options.

sudo nano /etc/systemd/system/docker.service.d/options.conf

==> How to create your first Docker Image using Java?

Now make it look like this and save the file when you're done:

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375

Now, reload the systemd daemon and restart the docker service:

# Reload the systemd daemon.
sudo systemctl daemon-reload

# Restart Docker.
sudo systemctl restart docker

That’s going to let you continue to connect to the Docker daemon from within the VM thanks to -H unix://, but it also exposes the Docker Daemon with -H tcp://0.0.0.0:2375 so that anyone can connect to it over the non-encrypted port.


Configuring your dev box to connect to the remote Docker daemon:

If you want to set DOCKER_HOST by default so it always connects remotely you can export it in your ~/.bashrc file. Here’s an example of that as a 1 liner:

echo "export DOCKER_HOST=tcp://X.X.X.X:2375" >> ~/.bashrc && source ~/.bashrc

That just adds the export line to your .bashrc file so it’s available every time you open your terminal. The source command reloads your bash configuration so it takes effect now.

Top 18 Docker Commands For Daily Usage

Testing

You can test the configuration using a simple curl command, like the following:

curl <docker-host-ip>:2375/v1.38/containers/json 

If you have any running containers, you will receive a non-empty json response.

Congratulations, you’re now able to connect to a remote Docker daemon.


Source: collabnix/dockerlabs


19. How to setup docker with selenium grid for cross browser testing?
Ans: click below link for details

Learn (API-Microservice)Testing+(CoreJava+UI)-SDET with Self Paced Videos and one LIVE Doubt Session

TRANING VIDEOS AVAILABLE with Live Doubt Session @4500/-(course-1 below,API TRaining Videos With ClassNotes and Coding Set) and 6500/- (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122
Entire course content can be found below:  COURSE CONTENT

Check below link for question and answers with code:

*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Mobile Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

Python Interview Question Set for QAE - SDET - SDE:
https://automationreinvented.blogspot.com/search/label/Python

No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

Introduction to Web Testing with Playwright

  Introduction to Web Testing with Playwright 📌  Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 📌  YouTube channel:  https://lnkd.in/gGUG...