Docker Local Install

2/12/2022by admin
  1. See Full List On
  2. Command Line Reference

As a developer or DevOps resource, you might have had a requirement of running an RDBMS database such as mssql server in your local machine (Windows/Mac)

  1. Step1: Install Docker Desktop in your Local machine. Step2: Validate If Docker CE is running. Step3: Start the Docker MSSQL 2017 Server. Step4: Check If the container is running. Step5: Try to Connect to this MSSQL Server using the SQL Client. VLOG – Screen record.
  2. To install and run DynamoDB local with Docker Compose: Download and install Docker Desktop. Copy the following code to a file and save it as docker-compose.yml.

In this post, we are going to cover, how to install and run MSSQL server as a Docker container in 5 easy steps.

Docker.local Now start a local registry (remove -d to run non-daemon mode): docker run -d -p 5000:5000 -restart=always -name registry registry:2 Now tag your image properly: docker tag ubuntu docker.local:5000/ubuntu Now push your image to local registry: docker push docker.local:5000/ubuntu Verify that image is pushed. Install Docker on the virtual machine. There are also methods of controlling cloud computing resources from a local command line, where you type special commands to deploy Docker containers. These can be very useful, but they tend to be more complicated to use than the basic Docker command line. Installing Docker. Mail Server Linux Installation in 10 minutes? Here you will learn step-by-step how to install and set up all necessary applications to have a fully featured.

Steps to run MSSQL server in your localhost

  1. Install Docker desktop in your local machine (windows/mac)
  2. Validate if Docker Container Engine is running
  3. Run the MSSQL container using docker run command
  4. Check if the container is running with docker ps command
  5. Connect to the database with SQL CLI tools

Step1: Install Docker Desktop in your Local machine

Refer the following link and install Docker CE in your local machine. MAC/Windows

Step2: Validate If Docker CE is running

Open the command prompt (Windows) or terminal (Mac) and type the following command to make sure that the Docker CLI is installed and Docker CE is running

You will get a connection error like this if your docker daemon (or) docker desktop is not running

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Step3: Start the Docker MSSQL 2017 Server

Now you have a running Docker Engine on your local system and you can technically run any Docker images.

This is the command you should run in order to start the ms sql server container

In the previous command, You can update the value of SA_PASSWORD as per your choice

The Docker image gets downloaded if it is not already present. if the image is already available in local, It would just print the container id and start the mssql container.

Here we have named the container as mssql2017 you can change this name as well as per your requirement.

Step4: Check If the container is running

You can validate if the container is running and staying alive by executing the following command

You should see your container running with the name you have given in the previous step, in my case it is mssql2017

Step5: Try to Connect to this MSSQL Server using the SQL Client

You can use the following connection properties in your SQL Client Software to test the connection

If you are not already having any SQL Client. I would recommend DBeaver. or if you prefer CLI based SQL client you can use sql-cli

DBeaver is a Single SQL Client for multiple different databases such as MS SQL, Oracle, MySql etc

Create a New Connection in DBeaver and Enter the aforementioned connection details and click on test connection to validate

If you are getting Connected message on the Test Connection. You are Good.

If you are preferring SQL-CLI way. Refer this article or the below Screen clip to know how to use it.

VLOG – Screen record

Refer the following screen record or terminal capture to understand the entire steps better.

Let me know in comments if you need further help or have any questions.

Is there a better way you can think of running MSSQL or ORACLE in your local? Let me know in comments

Sarav AK

Follow us on Facebook or Twitter
For more practical videos and tutorials. Subscribe to our channel
Find me on Linkedin My Profile
For any Consultation or to hire us [email protected]
If you like this article. Show your Support! Buy me a Coffee.

Signup for Exclusive 'Subscriber-only' Content

More from Middleware Inventory

  • Docker Run Image as Container - Create Container From Docker Image

    In this post, we are going to see how to create an image and run the image as a container and manage it. Before we proceed further, it is indispensable, that we are aware of what is an Image and What is a Container. So let us begin from there.…

  • Docker Weblogic : Run Oracle Weblogic 12c on Docker

    The Introduction to Docker Weblogic In this post, we are going to be exploring the quick and easy option available to get started with weblogic and Docker. In this post, we are going to see how to create a weblogic container in docker in a few easy steps. The post's…

  • PowerShell tail file - Windows tail command

    PowerShell is a powerful tool and it enables the Windows servers to compete with the Shell and Linux command line features. One of the useful command in linux is tail which helps us to view the file as it gets updated mostly used to view the log files. For instance,…

  • Docker Tomcat Example - Dockerfile for Tomcat, Docker Tomcat Image

    In this post, we are going to learn how to install a Tomcat Application Server or Web Container on Docker and Deploy web applications into the Tomcat running inside Docker. This post is all about Docker Tomcat and deploying war web application into tomcat docker, Sample Docker Tomcat image, Dockerfile…

  • Netstat command windows - Usage and Examples

    Introduction Like Linux, Windows does have a netstat command and it can come handy when you are in need of network-related monitoring and troubleshooting. Consider you have any of the following requirement How to find who or which process owns the port in Windows Server To see how many HTTP/DB…

In this post, I describe how to install WSL 2 to serve as the backend for Docker Desktop for Windows. Previously I've always worked with Linux in a Virtual Machine using something like VMWare or Virtual Box, but I decided to give Docker Desktop a try, and was pleasantly surprised by the experience!

I'll start by describing how to install WSL 2 based on the install documents, then show how to install Docker Desktop. Finally, I show the the experience of running a container and how it looks in Docker Desktop.

Installing WSL2

The Windows Subsystem for Linux (WSL) is a way to run a full Linux environment on your Windows machine, without having to install a 'heavier' virtual machine, such as Virtual Box, VM Ware, or Hyper-V. WSL 2 also provides a mechanism for running Docker (with Linux containers) on your Windows machine. We'll install it as a prerequisite for Docker Desktop for Windows.

If you're running Windows Home, WSL 2 is the only way to run Docker Desktop. On Windows Pro, you can also use Hyper-V, but that is deprecated now, so WSL 2 is the way to go in all cases.

1. Install WSL 1

We'll start by installing WSL 1 by enabling the WSL feature.

Open PowerShell as Administrator (I hit the Start key, type powershell and hit ctrl+shift+enter to open an elevated command prompt). Run the following, to enable WSL 1

You should see the following:

That enables WSL, but we're going to enable the newer WSL 2 version, which Docker Desktop can use to run the VM it needs to run containers.

2. Enable the Virtual Machine feature

WSL 2 uses a lightweight VM, so you need to enable the Virtual Machine feature available in Windows 10 version 1903 and higher. In the same, elevated command prompt, run:

You should see something like the following:

3. Restart

Time to restart your machine to ensure everything is registered correctly.

4. Install the WSL 2 update

Download the WSL2 Linux kernel update package for x64 machines and install it.

Note, if you see the following error when running the update, make sure you've restarted your machine afer installing the WSL 1 and VM features:

The installer runs very quickly, and hopefully you'll see a confirmation screen, something like the following:

5. Set WSL 2 as your default version

This is an easy step, just run wsl --set-default-version 2 in any PowerShell window:

6. (Optional) Install a Linux distribution

We actually don't need to install a Linux distribution to use Docker Desktop, but if you want to shell into Linux directly, you'll need to install one. You can install a distribution directly from the Microsoft Store.

The first time you launch the distribution, the distribution will extract and install, and you'll need to set a username and password.

Install docker on local machine

7. (Optional) Add to Windows Terminal

If you're using Windows Terminal (you should be!) you can configure it to open your WSL distribution. The easiest way to do this is to open up the settings.json file and reset it. You can do this by deleting the contents of the file—Terminal will automatically repopulate it with the defaults, which will include a tab for WSL.

Obviously you won't want to lose your setting customisations, so make sure to backup the contents of the file first!

You're looking for WSL in the profiles list—add that to you profile list, and you'll be able to quickly open up your WSL instance from Windows Terminal!

That's the prerequisite starter for Docker Desktop covered, so now lets get to the main course!

Installing Docker Desktop for Windows

1. Download and Install

Head to the Docker Desktop website and download the Installer for Windows.. This is a hefty ~500MB, but once it's finished, run the installer.

On the first screen, ensure you keep 'Install required components for WSL 2' checked:

After clicking OK, the installer will unpack a whole load of files:

Before finally prompting you to log out of your Windows account to complete the installation:

2. Logout and back in

The Docker Desktop installer will automatically log you out of your Windows account on completion. When you sign back in, you'll get a notification that Docker is starting the Linux Containers WSL 2 backend. Eventually, the main Docker Desktop window will pop up, and offer you a tutorial

3. Give it a try!

With Docker Desktop installed, you now have the docker command available in your command prompt:

Now it's installed, let's take it for a spin!

Trying out Docker Desktop for Windows

See Full List On

For simplicity, we'll run one of the .NET 5.0 sample apps available on DockerHub:

This is a simple Razor Pages app, packaged in a Docker image, and ready to run. You can see the Dockerfile for the app here. When you run the above command Docker will pull the image, run it and start listening:

If you navigate to http://localhost:8000/, you'll see the app running there—a Linux container, running on Windows 🤯

The interesting thing, which I didn't realise until I installed it, is that Docker Desktop for Windows installs a very nice UI for managing your containers!

If you click on the my-sample container row, you'll see the logs for the container:

You can also inspect the environment variables, view stats about the container, or click CLI to open a shell inside (exec into) the container! You can do all these things from the command line obviously, and if you're automating things, that's definitely the right option. For casual or local development, personally I find you can't beat a nice GUI!


Command Line Reference

In this post I described how to Install WSL, upgrade it to WSL 2, and how to install Docker Desktop. This requires a restart of Windows and a logout which is a bit annoying, but otherwise it went very smoothly. The Docker Desktop UI also looks very handy, in particular the ability to exec into a container—I'm always getting the CLI command wrong, so that will be very unseful!

Comments are closed.