

- #RUN DOCKER ON MAC LIKE SERVER FOR MAC#
- #RUN DOCKER ON MAC LIKE SERVER INSTALL#
- #RUN DOCKER ON MAC LIKE SERVER WINDOWS 10#
- #RUN DOCKER ON MAC LIKE SERVER PASSWORD#
Docker, however, it a great solution to allow me to run SQL Server containers on my Macbook without having to set up anything.
#RUN DOCKER ON MAC LIKE SERVER INSTALL#
Yes, I could install SQL Server on the OS but it’s my personal machine and I’m not that familiar with SQL on Linux (yet). When I shift working locations I work on my Macbook, and I still need access to a SQL Server instance. Of course, these days I’m maintaining social distancing so getting away from my desk to work elsewhere means working from my kitchen table for a change of scenery. It’s small footprint and ease of use allows me to easily shift working locations if needed.

However, my backup machine, is an Apple MacBook Pro. It remains docked at my desk where it happily helps me to go about my daily business.
#RUN DOCKER ON MAC LIKE SERVER WINDOWS 10#
That's all there is to it, you've now installed SQL Server on your Mac! If you knew the Microsoft of the 90's you probably never would have thought it would be so easy to install SQL Server on a Mac and especially on Linux as it is in 2020.My day to day work machine is a Windows 10 HP laptop. This makes it easier to maintain a list of DB modifications or additions in the mods.sql file for example. Note that we could have done everything from the docker-compose.yml file if we wanted to, but I decided to break it up into scripts.
#RUN DOCKER ON MAC LIKE SERVER PASSWORD#
It will be listening on port 1401, you can connect to it using SA and the password you set (eg DB_PASS environment variable). Just run the following in terminal from the directory that has your docker-compose.yml file: docker-compose upĪt this point it should boot up SQLServer. If you are not working with a SQL Server backup and just have some SQL create statements, you can just put them in mods.sql and comment out the line of the script that imports the database from a backup. opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "$MSSQL_SA_PASSWORD" -d ExampleDb -i /tmp/data/mods.sql opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "$MSSQL_SA_PASSWORD" -Q "RESTORE DATABASE ExampleDb FROM DISK='/tmp/data/myDB.bak' WITH MOVE 'ExampleDb' TO '/var/opt/mssql/data/ExampleDb.mdf', MOVE 'ExampleDb_log' TO '/var/opt/mssql/data/ExampleDb.ldf'" The folder structure looks like this: db/ Now I have a sub folder called db with a few other files. The password for the SA account will be set to the value of my DB_PASS environment variable, you may want to change how that works to suit your needs. The ports section is mapping SQL Server port 1433 to my local port 1401. Image: microsoft/mssql-server-linux:2017-latestĪ few key points here. Here's a simple docker-compose.yml file for running SQL Server on a Mac. You don't have to use docker-compose but I find it makes the process easy, especially if you leave a project and come back to it 6 months later. We will use docker-compose.yml to make it very easy to start or stop SQL Server on our Mac.
#RUN DOCKER ON MAC LIKE SERVER FOR MAC#
Once you have docker for Mac installed you should be able to run docker-compose -v from Terminal and it should output the version number.ĭocker Compose lets you define one or more servers (or docker containers) in a single YAML file. If you already have docker installed, great news for you, you can skip to the next step. I never thought this would be so easy, but here's how I've been doing this for the past few years.

So you use a Mac, but you need to run Microsoft SQL Server.
