To install the Mssql server 19 in Ubuntu 20.04, you need to follow these steps.
1. Clone the systemd image.
sudo docker run -d --name linuxamination --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro jrei/systemd-ubuntu:20.04
2. Log into the container
sudo docker exec -it linuxamination bash
3. Run the commands inside the container
apt update
4. Install dependent packages
apt install wget curl sudo software-properties-common gnupg2
5. Add microsoft keys in your apt repository.
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"
6. Update the repository
apt update
7. Install Mssql server
sudo apt install mssql-server
8. Configure Mssql server
/opt/mssql/bin/mssql-conf setup
While configuration, You need to select Express (Free) option if you do not have License key for Mssql server.
Then you need to accept the License terms and add a password for your mssql server.
If you get following error while configuring Mssql server
Ubuntu Docker Container Error - System has not been booted with systemd as init system (PID 1). Can't operate
Then you need to follow this tutorial from the beginning, you will not get this error. If you have launched a container from your existing Ubuntu Image and now you are following rest of the steps from this tutorial then you might get this error.
Take a look at here for the solution.
http://linuxamination.blogspot.com/2020/11/ubuntu-docker-container-error-system.html
or if you need complete guide of solution, follow this.
9.Now you need to install mssql tools, run the command in your container.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/19.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
10. Update the repository
sudo apt update
sudo ACCEPT_EULA=Y apt install mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
11. Now Connect to MS SQL console using command.
sqlcmd -S 127.0.0.1 -U SA
Enter the password you chose while configuration. Now you are on mssql command line.
12. Create database
1> create database mydb;
13. Get a list of databases:
1> select name from sys.databases;
2> go
You can see the solution in the following video.
Hi
ReplyDeleteWhen i run this (docker exec -it linuxamination bash) command, i am getting error saying your container is not running.
could you please help me.
Thanks,
Try to start the container using command
Deletedocker start containerid
Put the container id of container linuxamination in above command
If it doesn't start, it will throw an error. This will help to solve the issue. If it starts successfully, run that exec command again.