Mount Local file on windows to a Docker container

Imagine you have a web application container that needs to access configuration settings stored in a file on your host system. This file might contain sensitive information like database credentials or API keys. Storing such sensitive data directly within the container image can lead to security risks, particularly when sharing the image. To mitigate this issue, Docker provides storage options that help bridge the gap between container isolation and your host machine’s data.

Docker offers two primary storage options for persisting data and sharing files between the host machine and containers: volumes and bind mounts.

Here we will use the bind mount

docker run -it --mount type=bind,source=d:\\MyFolder\\temp,target=/app/data wordcounterapp:latest -s /app/data/config

e.g The above is the example of a console app running in a container . It counts the words in a sentence . I ve put a sentence in a file on my d drive in windows and mounted it to container and passed the argument 

I have a windows 11 host machine so my example is the use case where i have file in my local machine in a directory called "temp" and i want to mount it to a container .so i will mount the content of the directory on my source system to the container file system.
so in the above command , the source is d:\\MyFolder\\temp
target is /app/data/config

Note: Please make sure that file path is correct and there is no spaces for source and target values. for e.g
the space shown below between cmdline argument and value will also give error

create a dev container using vscode and push it docker hub

The following article describes how to create dev containers using vscode and publish it to docker hub .

1. Install Prerequisites

  • Docker: Install Docker Desktop from here.
  • VS Code: Install Visual Studio Code from here.
  • Remote – Containers Extension: Install the Remote – Containers extension in VS Code. You can find it in the Extensions view in VS Code .

2. Create a Dev Container Configuration

  1. Open your project in VS Code.
  2. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac) to open the Command Palette.
  3. Type and select Remote-Containers: Add Development Container Configuration Files.
  4. Choose a predefined container configuration that suits your project’s needs or customize your own.

This will create a .devcontainer folder with a devcontainer.json file in your project.

3. Customize devcontainer.json

Edit the devcontainer.json file to include any specific tools, extensions, or settings your project requires. Here’s an example:

4. Build and Open the Dev Container

  1. Reopen the Command Palette and select Remote-Containers: Reopen in Container.
  2. VS Code will rebuild the container and reopen your project inside it.

we could see the vs code opening the code in dev container

you can see that that the container has loaded and i am able to run the code from within the container

5. Push the Container to Docker Hub

we need to first make sure that we are authenticated successfully in the docker hub .so
First, log in to Docker Hub from your terminal using:

Then here i will use dev container CLI to build and publish images .

  1. Install DevContainer CLI using Node JS package manager npm as follows :

2. Build and Push the Container

devcontainer build --workspace-folder <path_to_your_workspace> --push true --image-name <your_dockerhub_username>/<your_image_name>:<version>

Replace <path_to_your_workspace>, <your_dockerhub_username>, <your_image_name>, and <version> with your actual values.
Note : This command need to be execute in the host file system not inside container

Here’s a breakdown of that command:

  • devcontainer build: This is the main command for building a development container. It’s part of the Dev Containers specification, which allows you to define your development environment as code.
  • --workspace-folder <my_repo>: This flag specifies the root folder of your workspace. Replace <my_repo> with the path to your repository. For example, if your repository is in a folder named project, you would use --workspace-folder project.
  • --push true: This flag indicates whether the built image should be pushed to a container registry. By setting it to true, the image will be pushed after the build.
  • --image-name <your_dockerhub_username>/<my_image_name>:<optional_image_version>: This flag specifies the name (and optionally the version) of the image. Replace <your_dockerhub_username> with the docker user name which you can find it once you login to docker.com under the profile .
    Replace <my_image_name> with the desired name for your image. You can also include an optional version tag by replacing <optional_image_version>. For example, myapp:latest.

for example , refer the above command
i am executing the devcontainer command from the root directory of my repo that contains .devcontainer folder which makes it easy . Hence you will see that i ve indicated a “.” (dot) after the –workspace-folder parameter switch .

Once i execute command , since you have already authenticated docker earlier it will push your image to the docker hub and if it is successful , you will get the following :

Azure CLI useful Commands

For the Use case where you need to Login to a GitRepo hosted on Azure Devops

Step 01 : Login to Azure Devops using Azure CLI (Command Line Interface)

az devops login –organization https://dev.azure.com/your-organization

You will be prompted to enter your PAT (Personal Access Token) (click here to see how PAT can be created )

Step 02 : Navigate to Your Repository Directory: Use cd to go to the directory where your repository is located or where you need to clone your Repository .

Step 03 : Run Git Commands: You can now run standard Git commands like git status, git add, git commit, and git push in your terminal.

Clone a particular repo within a github org

The following post outlines a scenario where you need to clone a repo within a github organization .
To clone a repo you use
git clone https://github.com/YOUR-ORGANIZATION/REPO-NAME
however if you use it for a repo that resides within an organization , as of date you will end up with an error :
fatal: repository ‘https ://github.com/ORGNAME/REPO-Name.git/’ not found
The solution is to use the following comand
git clone https://username@github.com/YOUR-ORGANIZATION/REPO-NAME.git
You’ll be prompted to enter your password or token
Hope this helps someone who faces this issue .

Installing Apache Web Server on Ubuntu WSL

Setting up an Apache web server on Ubuntu running within Windows Subsystem for Linux (WSL) can be a straightforward process that brings the power of Linux to your Windows environment. Here’s a concise guide to get you started:

  1. Update Your System: Before installing any new software, it’s always a good idea to update your package lists. Open your Ubuntu terminal and execute:
   sudo apt update

This ensures you have the latest information about available packages and their versions.

  1. Install Apache: To install the Apache web server, use the following command:
   sudo apt install apache2

This command installs the Apache2 package from the Ubuntu repositories.

  1. Start Apache Service: Once installed, you can start the Apache service using:
   sudo service apache2 start

This command will start the Apache server, and you should now have a running web server on your system.

  1. Verify Installation: To confirm that Apache is running, open a web browser and navigate to http://localhost. You should see the default Ubuntu Apache web page, indicating that the server is operational.
  2. Manage Apache Service: You can check the status of the Apache service with:
   systemctl status apache2

To stop, start, or restart Apache, you can use the stop, start, or restart options with the service command, respectively.

  1. Configure Your Environment: With Apache installed, you can begin configuring your environment to suit your development needs. This includes setting up virtual hosts, securing your server, and optimizing performance.

Remember, when working with WSL, you have the flexibility of a full Linux kernel at your disposal, allowing you to run a wide range of Linux software on Windows. Whether you’re developing websites, testing applications, or just exploring Linux, WSL paired with Apache provides a robust platform for your web server needs.

For a more detailed guide, including setting up SSL and advanced configurations, you can refer to online tutorials and resources that provide step-by-step instructions. Happy hosting!

Update Git on Windows

Upgrading Git on Windows: A Step-by-Step Guide

Git is an essential tool for developers, providing a robust version control system that is integral to modern software development. Keeping Git up-to-date ensures access to the latest features, improvements, and security patches. For Windows users, upgrading Git can be done through the command line with relative ease. Here’s a step-by-step guide to help you ensure your Git installation is current.

Step 1: Check Your Current Git Version

Before upgrading, it’s important to know which version of Git you’re currently running. Open Command Prompt or PowerShell and enter the following command:

git --version

This will display the version number of your installed Git.

Step 2: Update Git

The command to update Git on Windows depends on your current version. If you’re running a version between 2.14.2 and 2.16.1, use:

git update

For versions later than 2.16.1, the command changes to:

git update-git-for-windows

Running the appropriate command will either update your Git installation or inform you that you’re already using the latest version.

Step 3: Verify the Update

After running the update command, it’s a good practice to verify that the update was successful. Use the same command as in Step 1 to check your Git version again:

git --version

If the version number has changed, congratulations, you’ve successfully updated Git on your Windows machine!

Troubleshooting

If you encounter any issues or if your version of Git is older than 2.14.2, you may need to manually download the latest installer from Git’s official website and run it just like you would for a fresh installation.

By following these steps, you can keep your Git installation up-to-date and maintain a smooth workflow. Remember, staying current with software updates is not only about having the latest features but also about ensuring the security and efficiency of your development environment. Happy coding!

MSYS2 where does the package get installed ? I mean in which environment ?

In MSYS2, packages are installed into different environments based on the type of package and the environment you are using. Here are the main environments:

  1. MSYS: Contains Unix-like tools and is always active. Packages installed here are placed under /usr.
  2. MINGW32: For 32-bit MinGW-w64 packages, installed under /mingw3.
  3. MINGW64: For 64-bit MinGW-w64 packages, installed under /mingw64.
  4. UCRT64: Uses the Universal C Runtime, installed under /ucrt64.
  5. CLANG32: Uses the Clang toolchain for 32-bit, installed under /clang32.
  6. CLANG64: Uses the Clang toolchain for 64-bit, installed under /clang64.

MSYS2 How to know which is the default environment.

echo $MSYSTEM
This command will display the current environment, such as MSYSMINGW32MINGW64UCRT64CLANG32, or CLANG64

MSYS2 How to change the default environment ?

To change the default environment in MSYS2, you can set the MSYSTEM environment variable to the desired environment. Here’s how you can do it:

  • Open MSYS2 Terminal: Start the MSYS2 terminal.
  • Set the Environment Variable: Use the “export” command to set the “MSYSTEM” variable. For example, to switch to the “MINGW64” environment, you would use: export MSYSTEM=MINGW64
  • You can also create a shortcut that opens MSYS2 with a specific environment. Here’s how:
    • Create a Shortcut: Right-click on your desktop and select New > Shortcut.
    • Enter the Path: Enter the path to the MSYS2 executable followed by the desired environment.
      For example: C:\msys64\msys2_shell.cmd -mingw64
    • Name the Shortcut: Give your shortcut a name, like “MSYS2 MINGW64”, and click Finish.
      Now, you can use this shortcut to open MSYS2 directly in the “MINGW64” environment.

Once you change the default environment to MINGW64 and run the pacman -Suy command, the packages will be installed in the MINGW64 environment. Specifically, they will be placed under the /mingw64 directory.

Canvas app doesn’t show data from related records.

Solution : Refresh the Datasource and then save and publish the app . Detailed description is given below .

Description
I created a power apps with 2 text boxes where i am fetching logged in user’s Business unit and then country where he belongs .
Now , to make it clear
– i am using Dynamics 365 as a data source .
– tables involved , systemuser (User), business unit , country
i added a data source for User’s table .
Approach :
i add a global variable on start on the app where i got the user object based on the logged in user’s email address .I stored it in a variable called D365

I set the value of other 2 text boxes which should have the logged in user’s Business unit ID and country as shown below
D365User.'Business Unit'.Country.Name
D365User.'Business Unit'.Country.Country

Issue : However when i run the app it shows the data correctly for the 2 textboxes . However when i publish the app it doesn’t show any data .It showed “Getting Data ….” then blank

Solution : click “Refresh” Data source in the data source menu as shown below

then save and publish the app .

Find Operating System in Linux Using Bash

Accessing OS Information

The most straightforward method to check your OS details is by using the cat command on the /etc/os-release file. This file contains identification data of the Linux distribution and looks something like this:

$ cat /etc/os-release

You’ll receive output similar to:

NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"

This file is present in most modern Linux distributions and provides a standardized way to access OS information.

Using the lsb_release Command

Another method is to use the lsb_release command, which displays Linux Standard Base (LSB) and distribution-specific information:

$ lsb_release -a

The output will provide detailed information about the distribution:

Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal

However, it’s worth noting that lsb_release might not be installed by default on some systems.

The hostnamectl Command

For systemd-based systems, hostnamectl can also be used to query and change the system hostname and related settings, including the OS information:

$ hostnamectl

It will display a comprehensive view, including the OS details:

Operating System: Ubuntu 20.04.1 LTS
Kernel: Linux 5.4.0-42-generic
Architecture: x86-64

Learn By fun

Toy Assembly Kit  Building Your Own Racing Car

Dive into the world of excitement with a racing car kit that comes with lights and sounds. Learn to use a working drill to assemble the car, and have fun mixing and matching pieces to create colorful versions. It’s endless pit-stop fun for mini mechanics! Feel free to check out more details click here