<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tushar Gayakwad</title>
    <description>The latest articles on DEV Community by Tushar Gayakwad (@tusharops_29).</description>
    <link>https://dev.to/tusharops_29</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2199397%2F1de00bac-078f-4313-be68-72a25fc44ff4.png</url>
      <title>DEV Community: Tushar Gayakwad</title>
      <link>https://dev.to/tusharops_29</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tusharops_29"/>
    <language>en</language>
    <item>
      <title>SecureOpsFlow - End-to-End Deployment with Notifications and Secure.🚀</title>
      <dc:creator>Tushar Gayakwad</dc:creator>
      <pubDate>Wed, 25 Dec 2024 17:33:47 +0000</pubDate>
      <link>https://dev.to/tusharops_29/secureopsflow-end-to-end-deployment-with-notifications-and-secure-3p6o</link>
      <guid>https://dev.to/tusharops_29/secureopsflow-end-to-end-deployment-with-notifications-and-secure-3p6o</guid>
      <description>&lt;h1&gt;
  
  
  &lt;strong&gt;✨Introduction&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;This architecture represents an efficient and secure CI/CD pipeline to improve the development and release process while upholding good code quality, security, and automated approvals. Tools will include GitHub Actions, SonarQube, Docker, and AWS services, all incorporating mechanisms like approval and vulnerability scans using Docker images.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;🏗️SecureOpsFlow Architecture&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzjhqo4h9kdhnp54akq2l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzjhqo4h9kdhnp54akq2l.png" alt="Image description" width="800" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;📦SecureOpsFlow Project Setup Prerequisites&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Git with GitHub&lt;/strong&gt;: Version control system and code repository hosting&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Actions&lt;/strong&gt;: Automation tool for CI/CD flow triggered by code changes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SonarQube&lt;/strong&gt;: A code quality issue with possible bugs, anti-patterns &amp;amp; security hotspots.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker&lt;/strong&gt;: A tool for packaging applications into the best possible portable images,&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Compose&lt;/strong&gt;: A tool used to define and manage multi-container Docker applications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS EC2&lt;/strong&gt;: Virtual servers in the cloud for hosting and running your Docker containers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS ECR&lt;/strong&gt;: A host of Docker registries that provides storage, encryption, and cross-region connectivity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS CloudFront&lt;/strong&gt;: A fast, secure, and inexpensive CDN Service that delivers highly secured content quickly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GoDaddy&lt;/strong&gt;: GoDaddy is a site where you can find your website's unique public-facing domain name and register it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📋Step-by-Step Project Setup and Explanation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🛠️1. Create EC2 Machine for web service deployment&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Log in to AWS
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Move to the &lt;a href="https://aws.amazon.com" rel="noopener noreferrer"&gt;AWS&lt;/a&gt; Control Console.&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;EC2 Dashboard.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Launch Instance
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Continue to &lt;strong&gt;Launch Instances&lt;/strong&gt; for instance type from the "Instances" tab.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. Instance Configuration.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt;: Input the name of your instance (e.g.: SecureOpsFlow_Web).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Instance Type&lt;/strong&gt;: Choose t2. medium.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key pair&lt;/strong&gt; Create or Select a Key Pair for SSH Access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network Settings&lt;/strong&gt;: Chose security group.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage&lt;/strong&gt;: Customize storage (ie 15 GB, or more if needed).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4. Launch the Instance
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Verify your settings, and then choose Launch Instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhivv7qw8bn5cmz1is3ny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhivv7qw8bn5cmz1is3ny.png" alt="Image description" width="800" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🧩2. Setup a SonarQube on SecureOpsFlow_Web&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. SSH into the EC2 Instance
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Use your terminal to connect to the EC2 instance:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i "your-key.pem" ubuntu@your-ec2-public-ip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Install a Docker and Docker-compose
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Using these commands:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum update -y
sudo yum install docker -y
sudo service docker start
sudo usermod -a -G docker $USER
sudo curl -L "https://github.com/docker/compose/releases/download/2.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. Clone the Repository
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Clone your GitHub repository:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/TusharGayakwad/SecureOpsFlow.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Go into the repository directory:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd SecureOpsFlow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Run Docker Compose
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Now run the command for running Docker Compose:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose -f SonarQube_Setup_compose.yml up --build -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: After running this command, open a 9000 port in the instance security group to access a SOnarQube container.&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Verify the Setup
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Check if the containers are up and running:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh7zv114j9p5ea8kbk8cn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh7zv114j9p5ea8kbk8cn.png" alt="Image description" width="800" height="49"&gt;&lt;/a&gt;&lt;br&gt;
Open a browser and use the EC2 public IP and the configured port for accessing the SonarQube,(e.g., http://:9000 for SonarQube).&lt;/p&gt;
&lt;h4&gt;
  
  
  7. Configure a Project in SonarQube
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Log in to SonarQube&lt;/strong&gt; : Open your SonarQube instance (e.g., &lt;a href="http://instance_public_ip:9000" rel="noopener noreferrer"&gt;http://instance_public_ip:9000&lt;/a&gt;) and log in using the default password (default: admin/admin, change the password after logging in).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create a project&lt;/strong&gt; : Go to Projects &amp;gt; Create Project.&lt;br&gt;
(Write a project name and a key that has not yet been used, then click Set Up.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generate a Token&lt;/strong&gt; : Click on Generate Token, name it (e.g., SecureOpsFlow_Token), and store it in a safe location.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Select a Scanner&lt;/strong&gt; : Choose your build tool (e.g. SonarScanner CLI).&lt;br&gt;
Follow the instructions to download and set up the scanner.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add Configuration&lt;/strong&gt; :&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi5dxjwu6obcf7krw44o2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi5dxjwu6obcf7krw44o2.png" alt="Image description" width="585" height="173"&gt;&lt;/a&gt;Update the configuration in the main.yml file(.github/workflows/main.yml) place of the project key, host URL, and log in. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;add a github action secret&lt;/strong&gt; :&lt;br&gt;
Go on the github&amp;gt; settings&amp;gt;sacrets and variables&amp;gt;add secrets &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fog9yn5hy2q1brzkzvx6n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fog9yn5hy2q1brzkzvx6n.png" alt="Image description" width="784" height="103"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  8. Configure a Project in SonarQube
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Navigate to Quality Gates&lt;/strong&gt; : From the upper menu choose Quality Gates Press Create and give the name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add Conditions to Quality Gate&lt;/strong&gt; :  Add a condition by pressing Add Condition. This defines the rules for your Quality Gate. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Coverage&lt;/strong&gt;: Coverage is below 80% → FAIL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bugs&lt;/strong&gt;: The number of Bugs exceeds 0 → FAIL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vulnerabilities&lt;/strong&gt;: The number of Vulnerabilities is greater than 0 → FAIL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Smells&lt;/strong&gt;: Maintainability Rating is below A → FAIL.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Save the Quality Gate&lt;/strong&gt; - After adding all the desired conditions, click Save. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  9. Apply Quality Gate to your project.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Go to your project&lt;/strong&gt; : Click on &lt;strong&gt;Projects&lt;/strong&gt; and select &lt;strong&gt;your project&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assign the Quality Gate&lt;/strong&gt; : 
Go to &lt;strong&gt;Administration &amp;gt; Quality Gate&lt;/strong&gt;.
Select the newly created Quality Gate from the list.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  10. Update to the developer about the SonarQube quality checks way mail:
&lt;/h4&gt;

&lt;p&gt;If the SonarQube quality check becomes a &lt;strong&gt;"FAILED"&lt;/strong&gt; or &lt;strong&gt;"SUCCESS"&lt;/strong&gt; the pipeline sends a mail to the developer: &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqs9ug7dn6ymtqq9l9cv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqs9ug7dn6ymtqq9l9cv.png" alt="Image description" width="800" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Note: Update the username and secrets as follows:

&lt;ul&gt;
&lt;li&gt;Username: Use your office email.&lt;/li&gt;
&lt;li&gt;Password: Add a secret named &lt;code&gt;EMAIL_PASSWORD&lt;/code&gt; in GitHub Secrets.&lt;/li&gt;
&lt;li&gt;To: Add a secret named &lt;code&gt;DEVELOPER_EMAIL&lt;/code&gt; in GitHub Secrets with the developer's email.&lt;/li&gt;
&lt;li&gt;From: Add a secret named &lt;code&gt;OFFICIAL_EMAIL&lt;/code&gt; in GitHub Secrets with the office email.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;3. Build a Docker Image, Scan with Trivy Scanner Tool, and Push to AWS ECR:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Build a docker image way a docker file:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihvlg3s92amqp9mannoy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihvlg3s92amqp9mannoy.png" alt="Image description" width="376" height="319"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scan a docker image way a Trivy:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Trivy&lt;/strong&gt; is a lightweight and open-source vulnerability scanner built to find security issues in container images, file systems, and source code repositories. Simple and fast to use, it makes an excellent choice for vulnerability or misconfiguration scanning. Trivy works perfectly with DevOps tools and keeps the checks and your projects secure.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk172a3hbbk4krx7bhw16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk172a3hbbk4krx7bhw16.png" alt="Image description" width="800" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Send a vulnerability report to the DevOps team&lt;/strong&gt;:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldkgz8hx7pd89600myvf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldkgz8hx7pd89600myvf.png" alt="Image description" width="800" height="226"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Note:&lt;/strong&gt; Go to the GitHub Secrets and add a secret named &lt;code&gt;DEVOPS_GUY_EMAIL&lt;/code&gt; with the DevOps team email.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Configure AWS, Push Images to ECR, and send a final mail to the Manager&lt;/strong&gt;: &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9k2q323gimg7375roa7p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9k2q323gimg7375roa7p.png" alt="Image description" width="588" height="638"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Stage 1: Configuring AWS Credentials
&lt;/h4&gt;

&lt;p&gt;This stage is concerned with configuring the AWS Credentials necessary for performing actions with the ECR Service.&lt;br&gt;
We accomplish this through the aws-actions/configure-aws-credentials action, which accepts inputs due to the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access Key ID&lt;/li&gt;
&lt;li&gt;Secret Access Key&lt;/li&gt;
&lt;li&gt;Region (ap-south-1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:  Log in to AWS Console &amp;gt;  Click on User &amp;gt; Go to Security credentials tab &amp;gt; Create Access Key &amp;gt; Download the .csv file. &lt;/p&gt;
&lt;h4&gt;
  
  
  Stage 2: Logging into ECR and Pushing Docker Image
&lt;/h4&gt;

&lt;p&gt;Log in to Amazon ECR using the amazon-ecr-login action.Tag the Docker image (in this case, it is named secureopsflow) and push it to the ECR repository.&lt;br&gt;
The following commands would achieve this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker tag secureopsflow:l atest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Log in to AWS Console &amp;gt; Search ECR &amp;gt; Go to Repositories &amp;gt; Click Create Repository &amp;gt; Enter Repository Name (e.g., secureopsflow) &amp;gt; Click Create → Copy the Repository URI &lt;/p&gt;

&lt;h4&gt;
  
  
  Stage 3: Sending Notification Email to Manager
&lt;/h4&gt;

&lt;p&gt;The final step in the build stage involves sending an email to the manager once the Docker image is successfully pushed to ECR.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🚀4. Deployment to EC2:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr3vme21819m696yiidnn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr3vme21819m696yiidnn.png" alt="Image description" width="656" height="611"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Stage 1:Set up SSH Connection to EC2
&lt;/h4&gt;

&lt;p&gt;Now we need to create a secure SSH connection to the EC2 instance. This is done using the private SSH key stored in a GitHub secret for security purposes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Set up SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.EC2_SSH_KEY }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: create a secret for the SSH(EC2_SSH_KEY) &lt;/p&gt;

&lt;h4&gt;
  
  
  Stage 2: Deploy the Application to EC2
&lt;/h4&gt;

&lt;p&gt;Once connected via SSH, you run the deployment commands in the EC2 instance using Docker Compose. The workflow uses the ssh command to log into the EC2 instance and execute deployment commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Deploy Application to EC2
  run: |
    ssh -o StrictHostKeyChecking=no ubuntu@${{ secrets.EC2_HOST }} &amp;lt;&amp;lt; 'EOF'
    cd /home/ubuntu/SecureOpsFlow
    docker-compose -f compose.yml up -d
    EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The stepwise functioning is as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSH into the EC2 instance with username ubuntu and the EC2 Host IP stored as secret.&lt;/li&gt;
&lt;li&gt;Change directory to the application folder (/home/ubuntu/SecureOpsFlow).&lt;/li&gt;
&lt;li&gt;Issue the docker-compose up command in the detached mode to start the application. 
Note: create a secret for the Server IP address(EC2_HOST). &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Stage 3: Send Deployment Confirmation Email to the Manager:
&lt;/h4&gt;

&lt;p&gt;The final step of the deployment process sends a confirmation email to the manager upon the deployment's successful completion.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Connect a CloudFront to EC2🌐:&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Stage 1: crate Distribution:
&lt;/h4&gt;

&lt;p&gt;In the AWS console, go to CloudFront and create a new distribution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Origin Domain: Use your EC2 instance’s public IP or DNS as the origin.&lt;/li&gt;
&lt;li&gt;Cache Behavior: Set up the caching and protocol policies (HTTP or HTTPS) according to your needs.&lt;/li&gt;
&lt;li&gt;Create Distribution: Click Create to set up the distribution.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0cn28njocbsc3t2d1t7m.png" alt="Image description" width="800" height="95"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Stage 2: Update EC2 Security Group:
&lt;/h4&gt;

&lt;p&gt;Allow Traffic: Ensure your EC2 security group allows traffic from CloudFront’s IP ranges.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Configure GoDaddy (If using a custom domain)📝&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;DNS Settings: In GoDaddy, add a CNAME record to point your domain to the CloudFront distribution URL(&lt;a href="https://d1pm7k06iepqhp.cloudfront.net" rel="noopener noreferrer"&gt;https://d1pm7k06iepqhp.cloudfront.net&lt;/a&gt;).&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Thank you for taking the time to read my blog! I hope you found it insightful and engaging. 💡 Your support means a lot to me, and I look forward to sharing more content with you. Stay tuned! 🚀📚&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>devopsproject</category>
      <category>devops</category>
      <category>githubactions</category>
      <category>aws</category>
    </item>
    <item>
      <title>Docker Networking – Basics, Network Types &amp; Examples</title>
      <dc:creator>Tushar Gayakwad</dc:creator>
      <pubDate>Sun, 20 Oct 2024 09:21:17 +0000</pubDate>
      <link>https://dev.to/tusharops_29/docker-networking-basics-network-types-examples-5ed7</link>
      <guid>https://dev.to/tusharops_29/docker-networking-basics-network-types-examples-5ed7</guid>
      <description>&lt;h2&gt;
  
  
  Basic Understanding of Docker
&lt;/h2&gt;

&lt;p&gt;Docker is a platform that helps developers package applications and their dependencies into units called containers. Containers are lightweight, standalone environments that can run consistently on any machine with Docker installed, be it a local computer or a remote cloud server. This makes it easy to develop, test, and deploy applications in different environments without worrying about compatibility issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Concepts in Docker
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Docker Image:&lt;/strong&gt; A Docker image is like a blueprint for containers. It contains everything the application needs to run—such as the code, system tools, libraries, and settings. Images are reusable, so you can use the same image on different machines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker Container:&lt;/strong&gt; A container is a running instance of a Docker image. It’s isolated from other containers and the host system, ensuring that the application behaves the same everywhere. Containers are lightweight because they share the host machine’s operating system kernel, unlike traditional virtual machines that need a full OS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dockerfile:&lt;/strong&gt; A Dockerfile is a simple text file with instructions for building a Docker image. It defines the base image (e.g., Ubuntu or Alpine), the application code, and the steps required to set up the environment. When you build an image from a Dockerfile, Docker follows the instructions and packages everything into a container-ready image.&lt;/p&gt;

&lt;p&gt;for deep knowledge refer to a &lt;a href="https://docs.docker.com/get-started/docker-overview/" rel="noopener noreferrer"&gt;Docker Doc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdua3laywt0i2tq0psppf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdua3laywt0i2tq0psppf.jpg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Network Types
&lt;/h2&gt;

&lt;p&gt;Docker has a built-in networking system that manages communication between containers, the Docker host, and external networks. It supports different types of networks to handle a range of use cases, ensuring secure and flexible communication within containerized environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Networks
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;bridge&lt;/li&gt;
&lt;li&gt;host&lt;/li&gt;
&lt;li&gt;overlay&lt;/li&gt;
&lt;li&gt;IPvLAN&lt;/li&gt;
&lt;li&gt;macvlan&lt;/li&gt;
&lt;li&gt;None
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv697cwwyg9btexbo7opo.jpg" alt="Image description" width="800" height="800"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. bridge&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Bridge network is a default network, Bridge networks in Docker create a virtual connection between the host system and the containers. Containers in this network can communicate with each other but are isolated from external networks unless specifically configured.&lt;/p&gt;

&lt;p&gt;Each container gets its IP address within the bridge network. Through the bridge, containers can access the local network (LAN) and the internet, but they won’t appear as separate physical devices on the LAN. This type of network is commonly used for container communication on a single host.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. host&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In host network mode, Docker containers directly share the host’s network, meaning there’s no network isolation between the container and the host. The container uses the same IP address as the host, and any ports exposed by the container are bound directly to the host’s network. For instance, if a container is configured to listen on port 80, it will bind to the host's IP and port 80 (:80). This setup can improve performance since there’s no virtual network layer, but it sacrifices the isolation and security offered by other Docker network modes. It's often used for specific cases requiring direct access to the host network.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. overlay&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Overlay networks are used in Docker to connect containers running on different hosts, allowing them to communicate as if they were on the same network. This type of network spans multiple Docker hosts and doesn't require OS-level routing, making it useful for scaling applications across distributed systems.&lt;/p&gt;

&lt;p&gt;Overlay networks are essential for Docker Swarm clusters, but they can also be used independently to connect containers across separate Docker Engine instances. This enables you to build distributed environments where containers from different hosts can communicate seamlessly, simulating a Swarm-like setup without using it.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. IPvLAN&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;IPvlan is a networking option that allows you to manage how IP addresses are assigned to your Docker containers. This means you can better organize your network traffic by tagging it with VLANs, which helps separate different data types. This setup is instrumental if you want to connect your containerized applications directly to a physical network, like your office network while improving performance compared to standard bridge networks. Overall, IPvlan helps create a more efficient and organized network environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. macvlan&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Macvlan allows each container to act like a physical device on the network. By assigning a unique MAC address to each container, it makes them recognizable as separate devices. To use macvlan, you need to dedicate one of your host's network interfaces to this purpose. This means the external network must be capable of handling multiple MAC addresses. Macvlan is great for scenarios where containers need to be treated like independent devices, such as for network monitoring or when specific network permissions are required. This way, you get the benefits of containerization while still having the flexibility of physical network devices.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;6. None&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A "none" Docker network is a special network type where the container doesn't have any network interface, except a loopback interface (lo). Essentially, it isolates the container entirely from any external network connectivity. This is useful when you want to ensure that the container doesn't communicate with the outside world or other containers unless explicitly connected to another network.&lt;/p&gt;

&lt;p&gt;In short, a container on the "none" network has no external network access by default.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Docker Networking Works
&lt;/h2&gt;

&lt;p&gt;Docker uses your host's network to enable containers to communicate. It does this by setting up special rules using &lt;strong&gt;IPtables&lt;/strong&gt;, a tool in Linux that controls how traffic moves through the network. These rules automatically send the right traffic to your containers, so you don't need to set them up manually.&lt;/p&gt;

&lt;p&gt;Each Docker container has its virtual network environment, called a network namespace, which keeps it isolated. Docker also creates virtual network interfaces on the host, allowing the containers to communicate with the outside world using the host’s network.&lt;/p&gt;

&lt;p&gt;Although the process behind Docker networking is complex, Docker handles everything for you, making it easy to use. You can find more details in Docker's documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic commands for Docker Network
&lt;/h2&gt;

&lt;p&gt;Here are the basic commands for creating and managing Docker networks:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Create a Docker Network
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create my-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a network named my-network. &lt;/p&gt;

&lt;h3&gt;
  
  
  2. List Docker Networks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shows all the existing Docker networks on your system.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Inspect a Docker Network
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network inspect my-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Provides detailed information about the my-network, such as connected containers, subnet, and configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Remove a Docker Network
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network rm my-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deletes the network my-network (only if no containers are connected to it).&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Remove all networks with a single command
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating a Docker Network
&lt;/h3&gt;

&lt;p&gt;To create a new network, use the docker network create command. You can specify the driver (like bridge or host) with the -d flag. If you don't include this flag, Docker will create a bridge network by default.&lt;/p&gt;

&lt;p&gt;Run the following command in your first terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network create demo-network -d bridge
50ed05634f6a3312e56700ef683ca39df44bfc826e2e4da9179c2593c79910f9 ---output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Connecting Containers to Networks
&lt;/h3&gt;

&lt;p&gt;You can connect new containers to a network using the --network flag in the docker run command. In your second terminal , run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run -it --rm --name container1 --network demo-network busybox:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, open your third terminal window and start another container without the --network flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run -it --rm --name container2 busybox:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, try to communicate between the two containers using their names:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# in container1
/ # ping container2
ping: bad address 'container2'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the containers are not on the same network, they can't communicate yet.&lt;/p&gt;

&lt;p&gt;To connect container2 to the network, use the first terminal window:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network connect demo-network container2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, both containers share the same network, allowing them to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;communicate:
#in container1
/ # ping container2
PING container2 (172.22.0.3): 56 data bytes
64 bytes from 172.22.0.3: seq=0 ttl=64 time=4.205 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using Host Networking
&lt;/h2&gt;

&lt;p&gt;While bridge networks are commonly used to connect containers, you can also use host networking, which connects containers directly to the host's network interfaces. To enable host networking, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run -d --name nginx --network host nginx:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this setup, NGINX listens on port 80 by default, and you can access it via localhost:80 on your host:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl localhost:80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the NGINX welcome page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Disabling Networking
&lt;/h3&gt;

&lt;p&gt;To completely disable a container's network connectivity, you can attach it to the none network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run -it --rm --network none busybox:latest
/ # ping google.com
ping: bad address 'google.com'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This isolates the container, allowing you to sandbox unknown services.&lt;/p&gt;

&lt;h3&gt;
  
  
  Removing Containers from Networks
&lt;/h3&gt;

&lt;p&gt;Docker allows you to manage network connections without needing to restart your containers. You can remove a container from a network like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network disconnect demo-network container2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any changes you make will apply immediately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Networks with Docker Compose
&lt;/h2&gt;

&lt;p&gt;You can also use networks with Docker Compose services. When using Compose, services in your stack are automatically added to a shared bridge network, reducing the need for manual configuration. Here's an example Compose file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "3"
services:
  app:
    image: php:7.2-apache
  mysql:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: changeme
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deploy the stack with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker-compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see the output indicating that the network was created for your stack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding Extra Networks
&lt;/h3&gt;

&lt;p&gt;You can define additional networks in your Compose file. Specify the network in the top-level networks field and connect your services by referencing it in the networks field for each service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "3"
services:
  app:
    image: php:7.2-apache
    networks:
      - db
  helper:
    image: custom-image:latest
  mysql:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: changeme
    networks:
      - db
networks:
  db:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, only the app service can communicate with the mysql service, while the helper service cannot reach the database because it’s not on the same network.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>network</category>
      <category>kubernetes</category>
    </item>
  </channel>
</rss>
