Containers are all the rage at the moment and frankly i get it. You never have to worry about a mismatch between development and prod. You can containerize just about any type of application including asp.net using windows containers. Today we will cover running an mssql database on a digital ocean droplet. Digital Ocean is a very cost effective and easy to run cloud provider. They offer many different templates for one click apps including a droplet that includes Docker . Docker is the main player in the container space and has set the standard for creating containers. Containers are sort of an abstracted version of a virtual machine.
So, what we are going to do is run the containerized image of sql server on a digital ocean droplet.
Step 1) Create an account on digital ocean and create a droplet. The caveat here is that the droplet must have at least 4gb of ram because thats what sql needs. This eliminates using the most cost effective option of $5/month. The one we need is $20/month.
Step 2) Click the create button on the top right of the screen and select One-click apps
Step 3) Choose your droplet size, name, and create!
Once that process is done the fun begins!
You can SSH into your new machine. I personally use the console. You’ll get an email with your root password and will be prompted to create a new password on log in.
First thing we want to do is pull the latest docker image for sql server from the microsoft docker hub run
docker pull mcr.microsoft.com/mssql/server
This will pull the latest docker image into your machine. You then want to run the docker run command.
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest
This will start your container and expose sql server on port 1433. Remember to set your password to something compliant with sql server. Thats it! If you run
docker ps -a
You should see your running container!
After that you can do all sorts of stuff. Mainly using SSMS to log into your sql instance and add a database. The address will be the IP of your droplet XXX.XXX.XX.25,1433
The username is SA and the password is the strong password you created.