DEV Community

Dendi Handian
Dendi Handian

Posted on • Edited on

MS SQL Server and Adminer in Laradock

Local server solution like XAMPP, WAMP or Laragon doesn't provide MSSQL server rdbms out of the box, so the developers should install it separately and manually. Good thing if you are using Laradock all along, MSSQL is already included and easy to setup as easy as running MySQL and PostgreSQL in Laradock. Or Alternatively, you can run only MSSQL in Laradock and let's the project from other local server access it through localhost. Here I will demonstrate how to run MSSQL + Adminer as the management UI in Laradock.

Running MSSQL Server Service

We will try to make sure the mssql service is running well before running the adminer. So to run mssql service, here is the command:



docker-compose up -d mssql


Enter fullscreen mode Exit fullscreen mode

To check if it's running or not, use docker-compose ps:



      Name                    Command               State                    Ports
----------------------------------------------------------------------------------------------------
laradock_mssql_1   /opt/mssql/bin/nonroot_msg ...   Up      0.0.0.0:1433->1433/tcp,:::1433->1433/tcp


Enter fullscreen mode Exit fullscreen mode

And when we check the resource usage using docker stats, here is the result:



CONTAINER ID   NAME               CPU %     MEM USAGE / LIMIT     MEM %     NET I/O       BLOCK I/O   PIDS
1bab3ac14e94   laradock_mssql_1   1.45%     622.3MiB / 6.043GiB   10.06%    1.17kB / 0B   0B / 0B     138


Enter fullscreen mode Exit fullscreen mode

Running Adminer Service

Before build and run the adminer service, make these value set in your .env:



ADM_INSTALL_MSSQL=true
PHP_FPM_INSTALL_MSSQL=true
WORKSPACE_INSTALL_MSSQL=true


Enter fullscreen mode Exit fullscreen mode

After that, then we can start build and run the service by this command:



docker-compose up -d adminer


Enter fullscreen mode Exit fullscreen mode

The adminer service depends on php-fpm service, while the php-fpm service depends on workspace service. So these service will be automatically built run before the adminer.

The docker-compose ps result with the current services:



           Name                          Command               State                                                           Ports
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------laradock_adminer_1            entrypoint.sh docker-php-e ...   Up      0.0.0.0:8081->8080/tcp,:::8081->8080/tcp
laradock_docker-in-docker_1   dockerd-entrypoint.sh            Up      2375/tcp, 2376/tcp
laradock_mssql_1              /opt/mssql/bin/nonroot_msg ...   Up      0.0.0.0:1433->1433/tcp,:::1433->1433/tcp
laradock_php-fpm_1            docker-php-entrypoint php-fpm    Up      9000/tcp, 0.0.0.0:9003->9003/tcp,:::9003->9003/tcp
laradock_workspace_1          /sbin/my_init                    Up      0.0.0.0:2222->22/tcp,:::2222->22/tcp, 0.0.0.0:3000->3000/tcp,:::3000->3000/tcp,
                                                                       0.0.0.0:3001->3001/tcp,:::3001->3001/tcp, 0.0.0.0:4200->4200/tcp,:::4200->4200/tcp,
                                                                       0.0.0.0:8001->8000/tcp,:::8001->8000/tcp, 0.0.0.0:8080->8080/tcp,:::8080->8080/tcp


Enter fullscreen mode Exit fullscreen mode

The docker stats result with the current containers:



CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
2cfc8ac64e92 laradock_adminer_1 0.00% 6.605MiB / 6.043GiB 0.11% 1.52kB / 0B 0B / 0B 1

e8e5d86c2efe laradock_php-fpm_1 0.00% 17.38MiB / 6.043GiB 0.28% 796B / 0B 0B / 0B 3

06d7bd6073a6 laradock_workspace_1 0.00% 10MiB / 6.043GiB 0.16% 2.04kB / 0B 0B / 0B 6

1056353f4d06 laradock_docker-in-docker_1 2.55% 30.45MiB / 6.043GiB 0.49% 796B / 0B 0B / 0B 29

1bab3ac14e94 laradock_mssql_1 1.62% 673.8MiB / 6.043GiB 10.89% 286kB / 15.4kB 0B / 0B 149

Enter fullscreen mode Exit fullscreen mode




Accessing MSSQL Server using Adminer

The adminer login page can be accessed as default at http://localhost:8081 or the port number defined in ADM_PORT. Here is the login page looks like:

adminer login page

We can start to access the mssql through this login page.

  • For the system, use MS SQL (in my adminer version, the mssql was still in beta).
  • The server is mssql,
  • the username is sa,
  • the password is what defined in MSSQL_PASSWORD, and
  • the database is what defined in MSSQL_DATABASE.

After filling all those, hit that Login button and you should redirected to adminer database management interface.

adminer database management page

Top comments (1)

Collapse
 
maximoaraujo profile image
Maximiliano Araujo

When I try to log in I get the following error SQLSTATE[01002] Adaptive Server connection failed (mssql) (severity 9)