The previous section demonstrated how to use the nginx reverse proxy. Net core project container at:Docker learning notes 1 – deploy the. Net core 3.1 project to the docker container and use nginx reverse proxy (centos7) (2)
Next, we demonstrate the installation of Microsoft SQL Server in docker
Installation prerequisites:
1. The physical disk space shall not be less than 2GB
2. RAM memory shall not be less than 2GB, at least 3gb and above
Step 1: find out which versions are available
docker search mssql
Choose the first: Microsoft / MSSQL server linux
Step 2: image acquisition
docker pull microsoft/mssql-server-linux
The query version is: 2017 version
Step 3: create and run the container
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=AaBb2020' -p 11433:1433 -d --name=mssqlserver microsoft/mssql-server-linux
Parameter Description:
parameter | explain |
---|---|
-e ‘ACCEPT_EULA=Y’ | Setting this parameter indicates that you agree to the terms of use of SQL server, otherwise it cannot be used |
-e ‘SA_ Password = password ‘ | Set the password of SA account here (the password must contain upper and lower case English letters or special characters, and be greater than or equal to 8 digits) |
-p 11433:1433 | Mapping host external port 11433 to container port 1433 |
–name=mssqlserver | Set the container name to MSSqlServer |
-d | Run in the background |
Step 4: verify the link and enter the container
docker exec -it mssqlserver /bin/bash
Execute the following command: if > 1 appears, it means that the operation is successful and the sqlcmd session is entered at the same time
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -p
In the sqlcmd callback, you can use the following command to create a database:
Create database students -- enter to enter go to execute command
To end the sqlcmd session, enter the commandQUIT
:
Step 5: use Navicat links
External connection through the host’s IP requires the port number of the container to be added after the IP
Click test connection:
That’s the end of the demo, but there’s a question to consider next!
How to connect the container of. Net core project to MSSqlServer container, so that the two containers can communicate with each other!