How to use MSSQL Server on ARM based Mac.

How to use MSSQL Server on ARM based Mac M1,M2


Microsoft SQL Server can be run on Linux, Windows but they may not work with Apple Mac/Mac mini. We can’t change a just DBMS for new OS, different platform .

The fact that Mac/Mac mini with M2 chip is ideal for Multi platform development. It is better alternative for Windows Machine, since you are looking for a desktop.

We have two options to consider for getting things work, a Virtual machine dedicated to MSSQL or just containerise the SQL server which is a better choice.

VM don’t like Mac, I tried Virtual Box and Parallel. VB didn’t start up correctly. In case Parallel it didn’t get installed.

So we move to the Docker option. Most of the docker images (ARM based MSSQL) designed for Intel Mac ? For Mac with M1 and M2 (Apple Silicon).

Wee needs to user Rosetta for the transition from Intel to New M1/M2. It work behind the seen.

For complete Guide on Containerising MSSQL Server visit this Post.

Access Docker MSSQL Container from Parallel (Mac Mini M2)

How to access Docker Contained DB from Parallel.


Docker not working with Windows 11 in Parallels. Is there any way to use MSSQL with Parallel ? Yes.

Using the Mac Network IP and container exposed port number, we can access the server (Docker) within MSQL Management Studio or in a connection strings, separated by a single comma

Where Did I get the IP ?

In System Settings – Network- Find the IP.

connectionString="Data Source=192.168.20.100,1433;Password=mssql1Ipw;User Id=sa;Initial Catalog=dolphinedb;Integrated Security=False" />

The above code is sample sql connection string. Thanks for Docker.

Mac Mini M2 for Windows Developers

Moving from Windows to Mac


I got Mac Mini M2 last Saturday, wow. I love the Machine it saved my Desk. It is the base Model , with 8GB ,250 GB SSD.

I would like to share some of my experiences With M2. It is incredibly fast.

Running Windows 11 with Parallel VM

I’am using Parallels 8.0.1 , successfully configured windows 11 and installed Microsoft Visual Studio and it work without any trouble. Parallels allow me switch between Windows Apps and Mac Apps with ease and peace.

I did find some kinda of hanging and black out while the Mac went to sleep and wake from sleep.

Following Not working for me – Parallels

MSSQL Server

Docker

Above mentioned Apps can’t run on VM. So I decided to run it from Docker container which is on the Mac.

Apple Silicon and Docker

Some of the Docker Images not working with M2, it could be designed for Intel chip. So we need Rosetta for using such Docker images.

Installing Rosetta

Rosetta is referred as translater for Intel Mac Apps. You need not worry about any thing at all. Just install and move on.

 softwareupdate --install-rosetta

For more guides on Rosetta please visit MacHow

If you are a developer looking for Work Station with Multiple Display capabilities. Don’t wait to grab the deal today.

Deploy golang API in Digital Ocean using docker container

How deploy golang API with docker container


Before going forward, make sure golang program work locally and ready to deploy.

  • Prepare your project with Docker configuration (Dockerfile).
  • Also need to push the project to Github and update the module structure.
  • Golang modules should structured like github.com /username/ repo-name/module and re-initialize with
go mod init /username/repo-name

Droplet

Create Docker Droplet in the DigitalOcean Cloud. In the console (cloud) clone the Github repository and build docker image.

Let’s run the container, which is similar to what do you have done in development machine.

Please see golang docker guide for more instructions

Go to your browser and try accessing API , eg: 137.184.188.21:8080 and it should work.

Don’t have a DO Account yet ?, Use this $100 and get started ?

DigitalOcean Referral Badge

How to Containerize Golang app with Docker

How to containerize Golang app using Docker


To containerize a Golang app is similar to any other project. We need to use the base image for golandg and build the app.

Install Docker desktop , if you are on windows and create an account first. Then in the project create Dockerfile ( no extension required) with following command.

Save the file in root of the project

FROM  golang:1.18beta2-bullseye
RUN mkdir /app
ADD . /app
WORKDIR /app
RUN go build -o main .
CMD ["/app/main"]

Building the Docker Image

Go to the terminal and CD into the project folder and build the image. Docker image can be used to run different process.

docker build -t my-go-app . 

try to list image using docker images command.

Using the image

To use the image we created withrun command.

docker run -d -p 8080:8080 --name test1 my-go-app

The above command will run the image in detached mode, leaving console reedy for another execution.

It also exposed to port internal 8080:8080. Go to the browser and try localhost:8080 and it should have working.

Stopping, Starting and removing containers

Using docker stop <container-name/id>. Once it stopped can delete using docker rm container-name/id command.

Need to start again ? use the docker start command.

Wanna know running processes/ containers ? Try docker ps.

How to create a strapi project with Docker on Windows

How to create a strapi project with Docker in Windows


Starpi is new gen CMS for Node based projects, and it help us to build and manage content using customizable Admin UI.

Docker : When start using different technologies and database, Docker can make dev work easier. Developer usually need to work with different databases,frameworks, languages etc, which require super awesome computer.

Docker container help us to run development environment within a disposable,light weight container, it can include, Mysql, Mongo, Strapi and more etct .. Each container working based on Docker Images. You can explore more about Docker Images @ Docker Hub

How to start

First we need Docker for desktop get installed in Windows machine and then we need to use the Docker image to create strapi project. You need a Linux Subsystem get installed on Windows for proper working of Docker.

On the terminal please issue the following command create a project at the drive E named starpiProject.

docker run -it -p 1337:1337 -v E:\starpiProject:/srv/app strapi/strapi

This will run a docker container with interactive terminal mode (-it) and use local storage or volume which will create a strapi project starpiProject (on drive e) folder and run at the port of localhost:1337.

You can visit the the local host in a web brower which welcome you with user signup form.

Run the existing Project ?

The same command can be work for us and in case of non existed project, new one will be created.

docker run -it -p 1337:1337 -v E:\starpiProject:/srv/app strapi/strapi

Have a look at these docker posts

Docker-compose for projects

How use docker-compose to run MySQL database base for development


In the past docker posts we used docker run command to run containers using docker image and also the Dockerfile to create project image.

Sometimes we need to use/run a database in container during development, in such cases docker-compose came into light.

The Docker-Compose file

Docker-compose is a file at the root of your project, which has no extension and carry some special script. In our example we are configuring MySQL database.

version: '3.1'
services:
  db: 
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment: 
      MYSQL_ROOT_PASSWORD: example
      MYSQL_USER: development
      MYSQL_PASSWORD: development
      MYSQL_DATABASE: blog
    ports: 
      - 127.0.0.1:3306:3306

Up and Down

To start the docker-compose use the up command from the project root

docker-compose up -d

The down command used to remove and stop for stopping the container .

Checking the docker-compose containers

For listing the containers we can use

docker-compose ps

Accessing MySQL CLI

Login into the database and create some database ( as root)

docker exec -i some-id sh -c "exec -uroot -p password"

You can also use -u username for login as normal user and can execute basic sql operations such create database, tables and CURD operations on objects etc. Note that the database uses the default port of MySQL

We can stop running a container at any time using docker stop <id/name> and resume with docker start <id/name>

Following Docker Post may deserve a good read

Create a docker image of Node-Express API – Part II

How to build Node-Express project Docker Image using Node base image


In this post which is the continuation of Node-API Docker Image ( the Links are at the end of the post), create and run container using the image we build.

Lets check the existence of the image in docker using

docker image

Create the container

To build a container to run the API we need only the Image , all the depending Image will be automatically download by Docker.

docker run --name customer -d -p 3000:3000 user-api:latest

The above command will run, customer API in detached mode on port 3000.

Stop and Resume the container

We can stop running a container at any time using docker stop <id/name> and resume with docker start <id/name>

Following Docker Post may deserve a good read

Create a docker image of Node-Express API – Part I

How to build Node-Express project Docker Image.


In this post we are create Docker Image of a NodeExpress app which can be used to deploy and run the app. The image can be used to deploy multiple container as well. Following are the requirements for this tutorial

Requirements

  • NPM
  • Nodejs
  • VSCode/Atom

Node-Express API

Lets create a folder and create file index.js and paste the following API site content

const express = require('express')
const app=express()
require("dotenv").config();

app.get('/',(req,res)=>
  res.json([{name:'manoj',email:'codehat@outlook.com'
  },
  {name:'mariah',email:'codehat@outlook.com'
  }])
)
app.listen(process.env.PORT || 3000,()=>console.log(`Server running on port ${process.env.PORT}`))

Our API is a simple USER API which shows a list of users. Let’s setup the package.json file by issuing npm command and install dependencies

Howto to stop all containers at once in docker

How to stop all containers in docker


Docker is a developer tool which help us to run applications in an isolated environment, where you can start a service, app,local host, MySQL, SQL server, mongodb etc.

Get the container id

To stop container we can use ids of container they, can be , many. First thing we need grab all the ids using the

docker pa -aq

Then use those ids as arguments to stop command as follows

docker stop $(docker ps -aq)

that’s it

Docker posts that may help you