Docker Containers: Additional Commands

Docker Containers: Additional Commands

Rename a Container

docker rename CONTAINER NEW_NAME

Change the SA password

The SA account is a system administrator on the SQL Server instance that gets created during setup. After creating your SQL Server container, the MSSQL_SA_PASSWORD environment variable you specified is discoverable by running echo $MSSQL_SA_PASSWORD in the container. For security purposes, change your SA password.

  1. Choose a strong password to use for the SA user.
  2. Use docker exec to run sqlcmd to change the password using Transact-SQL. In the following example, replace the old password, <YourStrong!Passw0rd>, and the new password, <YourNewStrong!Passw0rd>, with your own password values.
docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd `
   -S localhost -U SA -P "<YourStrong!Passw0rd>" `
   -Q "ALTER LOGIN SA WITH PASSWORD='<YourNewStrong!Passw0rd>'"

Remove your container

If you want to remove the SQL Server container used in this tutorial, run the following commands:

docker stop SQLserver17
docker rm SQLserver17

Leave a Reply