Docker Setup

Command to show currently running docker containers.

docker ps

The ps argument displays a table with headers: IMAGE, COMMAND, CREATED, STATUS, PORTS, and NAMES.

Command to show all docker containers running or not.

docker ps -a

Command to stop a docker container.

docker stop NAME_OF_CONTAINER

Command to start a docker container.

docker start NAME_OF_CONTAINER

Command to remove a docker container.

docker rm NAME_OF_CONTAINER

Command to install MSSQL in a docker container. (Windows)

docker run --name sqlserver2019 -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Adam123456" -p 1401:1433 -d mcr.microsoft.com/mssql/server:2019-latest

Command to install PostgresSQL in a docker container.

docker run --name postgresql -p 5401:5432 -e POSTGRES_PASSWORD=Adam123456 -d postgres:latest

Command to open an interactive terminal (bash shell) in a docker container.

docker exec -it NAME_OF_CONTAINER bash

Bash shell command to show OS details.

cat /etc/os-release

Bash shell command to log into the SQL command-line tool.

/opt/mssql-tools/bin/sqlcmd -U sa -P Adam123456

SQL command to query the database version.

SELECT @@Version;
GO

More Docker commands, bash commands, and SQL commands are available in Chapter 2 of [Database Foundations: Intro to Databases].

Ex_Files_Database_Foundations_Intro\Chapter 2

Leave a Reply

Your email address will not be published. Required fields are marked *