DEV Community

Anuchit Prasertsang
Anuchit Prasertsang

Posted on

Switching Docker contexts between Rancher Desktop and Docker Desktop

In the fast-paced world of Docker development, having the flexibility to switch between different contexts is a game-changer. Whether you're using Rancher Desktop or Docker Desktop, the Docker CLI offers a smooth transition. In this quick read, we'll explore how to effortlessly switch between these two environments.

Switching from Rancher Desktop to Docker Desktop:

  1. Command:
    • If you're moving from Rancher Desktop to Docker Desktop, run:
docker context use default
Enter fullscreen mode Exit fullscreen mode
  • This sets your Docker context to the default, pointing to Docker Desktop.
  1. Verify:
    • Confirm the switch with:
docker info
Enter fullscreen mode Exit fullscreen mode
  • Ensure the output reflects the Docker Desktop daemon.

Switching from Docker Desktop to Rancher Desktop:

  1. Command:
    • Transitioning from Docker Desktop to Rancher Desktop is as easy as:
docker context use rancher-desktop
Enter fullscreen mode Exit fullscreen mode
  • Ensure Rancher Desktop is running before executing.
  1. Verify:
    • Confirm the switch with:
docker info
Enter fullscreen mode Exit fullscreen mode
  • Check for Rancher Desktop daemon information in the output.

Listing Available Contexts:

  • To see all available Docker contexts, use:
docker context ls
Enter fullscreen mode Exit fullscreen mode
  • The active context is marked with an asterisk.

Specifying Context in Commands:

  • Directly specify the context in your Docker commands:
docker --context rancher-desktop run -it my_image
Enter fullscreen mode Exit fullscreen mode
  • Replace rancher-desktop with your desired context.

Conclusion:

Effortlessly manage your Docker workflow by mastering context switching, empowering you to seamlessly transition between Rancher Desktop and Docker Desktop with just a few commands!

Happy Dockering! 🐳

Top comments (0)