Docker & Rancher Desktop Local Development Setup Guide - Yash-777/MyWorld GitHub Wiki
- What is Rancher Desktop?
- What is Docker?
- Installation & Setup
- Multi-Database Architecture
- MSSQL Server Setup
- MongoDB Setup
- Redis Setup
- Verification & Testing
- Common Errors & Solutions
Rancher Desktop is a lightweight, open-source container management platform that brings Docker desktop functionality to your local machine.
- Free alternative to Docker Desktop Pro
- Includes Kubernetes capability (optional)
- Container runtime options (Docker or containerd)
- Perfect for development and testing
- Works on Windows, macOS, and Linux
- Local development of containerized applications
- Testing multi-container environments
- CI/CD pipeline development
- Microservices testing
Docker is a containerization platform that packages your application and its dependencies into isolated containers.
- Image: Blueprint/template (like a snapshot)
- Container: Running instance of an image (like a VM, but lightweight)
- Registry: Repository where images are stored (Docker Hub)
- Dockerfile: Script that defines how to build an image
Docker allows each to run in an isolated container on your local machine without manual installation complexity.
-
Download Rancher Desktop
- Visit: https://rancherdesktop.io/
- Download for your OS (Windows/Mac/Linux)
- Run the installer and follow prompts
-
Launch Rancher Desktop
- After installation, open Rancher Desktop
- It will initialize the Docker environment
- Monitor the status bar (usually takes 1-2 minutes on first run)
-
Verify Installation
- Open PowerShell or Command Prompt
- If you use ConEmu64.exe, treat it as a Windows terminal emulator (tabs + split panes) for running Docker commands.
- Run:
docker --version - Expected:
Docker version X.XX.X, build ...
Docker Hub - Hello World! github
# Test with a simple hello-world container
docker run hello-worldExpected output: "Hello from Docker!"
Ξ» docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4f55086f7dd0: Pull complete
d5e71e642bf5: Download complete
Digest: sha256:f9078146db2e05e794366b1bfe584a14ea6317f44027d10ef7dad65279026885
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/ Ξ» docker images hello-world
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
hello-world:latest f9078146db2e 25.9kB 9.49kB U
This service uses three complementary databases:
| Database | Purpose | Port | Image |
|---|---|---|---|
| MSSQL (SQL Server 2019) | Relational data (JPA/Hibernate) | 1433 | mcr.microsoft.com/mssql/server:2019-latest |
| MongoDB | Document store for bookings/appointments | 27017 | mongo:latest |
| Redis | In-memory cache and data store (@RedisHash) |
6379 | redis:latest |
All three can run simultaneously on your local machine.
There are two separate MSSQL images:
-
mcr.microsoft.com/mssql/server:2019-latestβ SQL Server engine (database server) -
mcr.microsoft.com/mssql-toolsβ sqlcmd client tools (command-line access)
You need the server image to start the database, and the tools image to run commands.
docker run -e "ACCEPT_EULA=Y" `
-e "MSSQL_SA_PASSWORD=Strong@123" `
-p 1433:1433 `
--name mssql `
-d `
mcr.microsoft.com/mssql/server:2019-latestCommand Explanation:
-
docker runβ Create and start a new container -
-e "ACCEPT_EULA=Y"β Accept SQL Server license agreement (required) -
-e "MSSQL_SA_PASSWORD=Strong@123"β Set SA (admin) password -
-p 1433:1433β Map port 1433 (host:container) -
--name mssqlβ Container name (reference for later commands) -
-dβ Detached mode (runs in background) -
mcr.microsoft.com/mssql/server:2019-latestβ Image name and version
Expected Output:
acc164ea3b4205b6ff5988f0276756ff7d216ca2be9e05fdb6008bae93331fe0
(This is the container ID)
docker psExpected Output:
CONTAINER ID IMAGE CREATED STATUS PORTS
acc164ea3b42 mcr.microsoft.com/mssql/server:2019-latest 2 minutes ago Up 2 minutes 0.0.0.0:1433->1433/tcp
docker run -it --rm `
mcr.microsoft.com/mssql-tools `
/opt/mssql-tools/bin/sqlcmd `
-S host.docker.internal,1433 `
-U sa `
-P "Strong@123" `
-Q "CREATE DATABASE finance"Command Explanation:
-
docker run -it --rmβ Run container interactively and remove after exit -
mcr.microsoft.com/mssql-toolsβ Use the tools image (for sqlcmd) -
/opt/mssql-tools/bin/sqlcmdβ SQL command utility (path inside container) -
-S host.docker.internal,1433β Connect to MSSQL on this host/port (special hostname for Docker on Windows) -
-U saβ Username (SA = System Administrator) -
-P "Strong@123"β Password -
-Q "CREATE DATABASE finance"β SQL query to execute
Note: -it --rm ensures the temporary container is cleaned up after the command finishes.
docker run -it --rm `
mcr.microsoft.com/mssql-tools `
/opt/mssql-tools/bin/sqlcmd `
-S host.docker.internal,1433 `
-U sa `
-P "Strong@123" `
-Q "SELECT name FROM sys.databases"Expected Output:
name
-------
master
tempdb
model
msdb
finance
(5 rows affected)
The finance database should now appear in the list.
If you need to stop/restart:
# Stop the container
docker stop mssql
# Remove the container
docker rm mssql
# Then restart from Step 1 if neededdocker run -d `
--name mongodb `
-p 27017:27017 `
mongo:latestCommand Explanation:
-
docker run -dβ Run in detached mode (background) -
--name mongodbβ Container name -
-p 27017:27017β Map MongoDB port -
mongo:latestβ Official MongoDB image
Expected Output:
b90f57458ca512345abcd...
docker ps | findstr mongodbExpected Output:
CONTAINER ID IMAGE CREATED STATUS PORTS
b90f57458ca5 mongo:latest 2 hours ago Up 2 hours 0.0.0.0:27017->27017/tcp mongodb
docker exec -it mongodb mongoshExpected Output:
mongosh 6.0.0
connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh
Type "help" for help
test>
Exit with: exit
In application-dev.properties, MongoDB connection is typically:
spring.data.mongodb.uri=mongodb://localhost:27017/mongoDBCollection
spring.data.mongodb.database=mongoDBCollectionMongoDB runs with no authentication by default in development mode.
In pom.xml, this dependency only provides the Redis client:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>It does NOT install Redis server. You must run Redis in a container.
docker run -d `
--name redis `
-p 6379:6379 `
redis:latestCommand Explanation:
-
docker run -dβ Detached mode -
--name redisβ Container name -
-p 6379:6379β Map Redis port -
redis:latestβ Official Redis image
Expected Output:
9279c7188c8719739904835ed6563c9d502d5fc0fe58fccf48a730acad03b83f
docker ps | findstr redisExpected Output:
CONTAINER ID IMAGE CREATED STATUS PORTS
9279c7188c87 redis:latest 2 minutes ago Up 2 minutes 0.0.0.0:6379->6379/tcp redis
docker exec -it redis redis-cli pingExpected Output:
PONG
In application-dev.properties:
spring.redis.host=127.0.0.1
spring.redis.port=6379
# No authentication in dev mode by defaultdocker psExpected Output:
CONTAINER ID IMAGE STATUS PORTS
acc164ea3b42 mcr.microsoft.com/mssql/server:2019-latest Up 2 hours 0.0.0.0:1433->1433/tcp mssql
b90f57458ca5 mongo:latest Up 2 hours 0.0.0.0:27017->27017/tcp mongodb
9279c7188c87 redis:latest Up 2 hours 0.0.0.0:6379->6379/tcp redis
All three should be Up.
Run all three tests in sequence:
# Test MSSQL
docker run -it --rm mcr.microsoft.com/mssql-tools /opt/mssql-tools/bin/sqlcmd -S host.docker.internal,1433 -U sa -P "Strong@123" -Q "SELECT 1"
echo "MSSQL OK"
# Test MongoDB
docker exec -it mongodb mongosh --eval "db.adminCommand('ping')" > $null 2>&1
echo "MongoDB OK"
# Test Redis
docker exec -it redis redis-cli ping > $null 2>&1
echo "Redis OK"Sample output from your environment:
C:\Users\ymerugu
Ξ» docker run -it --rm mcr.microsoft.com/mssql-tools /opt/mssql-tools/bin/sqlcmd -S host.docker.internal,1433 -U sa -P "Strong@123" -Q "SELECT 1"
-----------
1
(1 rows affected)
C:\Users\ymerugu
Ξ» docker exec -it mongodb mongosh --eval "db.adminCommand('ping')" > $null 2>&1
C:\Users\ymerugu
Ξ» docker exec -it redis redis-cli ping > $null 2>&1
Error Message:
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user 'sa'.
Cause: Wrong hostname or MSSQL container not ready yet.
Solution:
- Use
host.docker.internalon Windows (notlocalhostor127.0.0.1) - Wait 10-15 seconds after starting the container (MSSQL takes time to initialize)
- Verify container is running:
docker ps | findstr mssql
Correct Command:
docker run -it --rm mcr.microsoft.com/mssql-tools /opt/mssql-tools/bin/sqlcmd -S host.docker.internal,1433 -U sa -P "Strong@123" -Q "SELECT 1"Error Message:
OCI runtime exec failed: exec failed: unable to start container process:
exec: "/opt/mssql-tools/bin/sqlcmd": stat /opt/mssql-tools/bin/sqlcmd: no such file or directory
Cause: Trying to run sqlcmd inside the MSSQL server container instead of the tools container.
Wrong Way:
docker exec -it mssql /opt/mssql-tools/bin/sqlcmd ... # β WRONGCorrect Way:
docker run -it --rm mcr.microsoft.com/mssql-tools /opt/mssql-tools/bin/sqlcmd ... # β
RIGHTThe mssql-tools image has sqlcmd; the server image does not.
Error Message:
org.springframework.data.redis.RedisConnectionFailureException:
Unable to connect to Redis; nested exception is
io.lettuce.core.RedisConnectionException: Unable to connect to 127.0.0.1/<unresolved>:6379
Cause: Redis container is not running.
Solution:
# Check if Redis is running
docker ps | findstr redis
# If not running, start it
docker run -d --name redis -p 6379:6379 redis
# Test connection
docker exec -it redis redis-cli pingError Message:
docker: Error response from daemon: driver failed programming external connectivity
on endpoint xyz: Bind for 0.0.0.0:1433 failed: port is already allocated.
Cause: Another service or container is using the port.
Solution:
# Option 1: Stop the existing container
docker stop <container-name>
# Option 2: Use a different port (map to different host port)
docker run -p 1434:1433 ... # Use 1434 instead of 1433 on host
# Option 3: Check what's using the port (Windows)
netstat -ano | findstr :1433Error Message:
docker ps # Container shows "Exited" status
Cause: Usually missing EULA acceptance or bad password format.
Solution:
# Correct log commands (Windows)
docker logs --tail 100 mssql
docker logs -f --tail 100 mssql
# Ensure command has both EULA and PASSWORD
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Strong@123" -p 1433:1433 --name mssql -d mcr.microsoft.com/mssql/server:2019-latestIf you run docker logs mssql tail -n 1000 -f, Docker returns:
docker: 'docker logs' requires 1 argument
Because tail -n 1000 -f must be passed as Docker options, not trailing shell args.
docker psdocker ps -adocker logs --tail 100 <container-name>
docker logs -f --tail 100 mssql # Follow logs in real-timedocker stop $(docker ps -q)docker rm $(docker ps -aq)docker statsdocker exec -it <container-name> /bin/bash# MSSQL (SQL Server 2019)
spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=finance;
spring.datasource.username=sa
spring.datasource.password=Strong@123
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
# MongoDB
spring.data.mongodb.uri=mongodb://localhost:27017/mongoDBCollection
spring.data.mongodb.database=mongoDBCollection
# Redis
spring.redis.host=localhost
spring.redis.port=6379-
Check all containers are running:
docker ps
-
If container not running, start it:
docker start <container-name>
-
Check logs for errors:
docker logs --tail 100 <container-name>
-
Test connection:
- MSSQL:
docker run -it --rm mcr.microsoft.com/mssql-tools /opt/mssql-tools/bin/sqlcmd -S host.docker.internal,1433 -U sa -P "Strong@123" -Q "SELECT 1" - MongoDB:
docker exec -it mongodb mongosh --eval "db.adminCommand('ping')" - Redis:
docker exec -it redis redis-cli ping
- MSSQL:
-
If still failing, remove and recreate:
docker stop <container-name> docker rm <container-name> # Then run docker run command again
- Rancher Desktop installed and running
-
docker --versionreturns version number - MSSQL container running on port 1433
- MongoDB container running on port 27017
- Redis container running on port 6379
- All three connections tested successfully
-
application-dev.propertiesupdated with correct connection strings - Spring Boot application starts without database connection errors