Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save letrongminh/5c81010df8768a1ee70d9c0641142d67 to your computer and use it in GitHub Desktop.
Save letrongminh/5c81010df8768a1ee70d9c0641142d67 to your computer and use it in GitHub Desktop.

Revisions

  1. letrongminh revised this gist Oct 15, 2024. 1 changed file with 0 additions and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@ If you've already created a Docker container with something like SQL Server 2019

    ```sh
    $ docker run -e ACCEPT_EULA=Y -e MSSQL_PID=Developer -e MSSQL_SA_PASSWORD=YourStrongPassw0rd -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
    57301203bac57455a118e0dbe6ff392cb19313375c134050e6ecd77414555e7e
    ```
    With reference to Configure SQL Server on Linux with the mssql-conf tool, get a root shell in the container:

  2. letrongminh revised this gist Oct 10, 2024. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions How enable SQL Server Agent in docker container existing.md
    Original file line number Diff line number Diff line change
    @@ -63,5 +63,9 @@ N.B. Within SQL Management Studio you need to right click the SQL Server Agent I

    Note you no longer have to do this if you enabled SQL server agent with the flag when initialising the container:
    ```sh
    docker run -d -p 1433:1433 --env ACCEPT_EULA=Y --env SA_PASSWORD='MYSUP3RS@!3' --env MSSQL_AGENT_ENABLED=True --name sql1 mcr.microsoft.com/mssql/server:2019-GDR1-ubuntu-16.04
    111
    docker run -d -p 1433:1433 --env ACCEPT_EULA=Y --env SA_PASSWORD='MYSUP3RS@!3' --env MSSQL_AGENT_ENABLED=True --name sql1 mcr.microsoft.com/mssql/server:2019-GDR1-ubuntu-16.04
    ```

    ---
    https://stackoverflow.com/questions/69038304/how-enable-sql-server-agent-in-docker-container-existing
    https://dbafromthecold.com/2017/10/25/running-sql-on-linux-containers-with-the-agent-installed/
  3. letrongminh renamed this gist Oct 10, 2024. 1 changed file with 41 additions and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -24,4 +24,44 @@ root@57301203bac5:/# /opt/mssql/bin/mssql-conf set sqlagent.enabled true
    ```
    root@57301203bac5:/# systemctl restart mssql-server.service
    ```
    If you get an error message such as `systemctl: command` not found then just stop and start the container for the changes to take effect.
    If you get an error message such as `systemctl: command` not found then just stop and start the container for the changes to take effect.


    ---

    From outside the container go into terminal by doing the following:

    ```sh
    sudo docker exec -it --user root sql1 "bash"
    ```
    The password will not be of the container.

    Next elevate yourself to superuser:

    ```sh
    su -
    ```
    Next enable sqlagent by changing the configuration file:

    ```sh
    /opt/mssql/bin/mssql-conf set sqlagent.enabled true
    ```
    Now exit the container by typing exit once to logout from root and next to exit from the container

    ```
    exit
    exit
    ```
    Finally restart the the docker container that has your microsoft sql server instance running

    (in this case tagged sql1)

    ```sh
    docker restart sql1
    ```
    N.B. Within SQL Management Studio you need to right click the SQL Server Agent Icon and refresh to verify it is up.

    Note you no longer have to do this if you enabled SQL server agent with the flag when initialising the container:
    ```sh
    docker run -d -p 1433:1433 --env ACCEPT_EULA=Y --env SA_PASSWORD='MYSUP3RS@!3' --env MSSQL_AGENT_ENABLED=True --name sql1 mcr.microsoft.com/mssql/server:2019-GDR1-ubuntu-16.04
    111
  4. letrongminh renamed this gist Oct 10, 2024. 1 changed file with 0 additions and 0 deletions.
  5. letrongminh created this gist Oct 10, 2024.
    27 changes: 27 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    If you've already created a Docker container with something like SQL Server 2019 Developer edition:

    ```sh
    $ docker run -e ACCEPT_EULA=Y -e MSSQL_PID=Developer -e MSSQL_SA_PASSWORD=YourStrongPassw0rd -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
    57301203bac57455a118e0dbe6ff392cb19313375c134050e6ecd77414555e7e
    ```
    With reference to Configure SQL Server on Linux with the mssql-conf tool, get a root shell in the container:

    ```bash
    $ docker exec -it --user root 57301203bac5 bash
    ```
    Then enable SQL Agent in the configuration file and restart the SQL Server service:

    ```bash
    root@57301203bac5:/# /opt/mssql/bin/mssql-conf set sqlagent.enabled true
    ```

    SQL Server needs to be restarted in order to apply this setting. Please run

    ```sh
    root@57301203bac5:/# /opt/mssql/bin/mssql-conf set sqlagent.enabled true
    'systemctl restart mssql-server.service'.
    ```
    ```
    root@57301203bac5:/# systemctl restart mssql-server.service
    ```
    If you get an error message such as `systemctl: command` not found then just stop and start the container for the changes to take effect.