Setting Up a Local Development Environment with Docker on Mac and Windows

brownian77

brownian77

Posted on March 8, 2024

Setting Up a Local Development Environment with Docker on Mac and Windows

Setting up a local development environment is crucial for developers to efficiently build, test, and debug their applications. Docker provides a convenient and consistent way to create isolated environments for development across different operating systems. In this article, we'll guide you through setting up a local development environment using Docker on both Mac and Windows platforms.

Prerequisites

Before getting started, make sure you have the following prerequisites installed on your system:

  • Docker Desktop: Download and install Docker Desktop for your respective operating system from the official Docker website.

Setting Up on Mac

Step 1: Install Docker Desktop

  1. Download Docker Desktop for Mac from the official Docker website.
  2. Double-click the downloaded .dmg file to open the installer.
  3. Drag the Docker icon to the Applications folder to install Docker Desktop.
  4. Open Docker Desktop from the Applications folder.

Step 2: Pull Ubuntu 20.04 Image

Open Terminal and run the following command to pull the Ubuntu 20.04 image from Docker Hub:

docker pull ubuntu:20.04
Enter fullscreen mode Exit fullscreen mode

Step 3: Run Ubuntu 20.04 Container

Run the following command to start a Docker container based on the Ubuntu 20.04 image:

docker run -it --name my-ubuntu-container ubuntu:20.04
Enter fullscreen mode Exit fullscreen mode

Step 4: Restarting the Container

To restart the container named "my-ubuntu-container" later, use the following command:

docker start my-ubuntu-container
Enter fullscreen mode Exit fullscreen mode

Setting Up on Windows

Step 1: Install Docker Desktop

  1. Download Docker Desktop for Windows from the official Docker website.
  2. Double-click the downloaded installer to start the installation process.
  3. Follow the on-screen instructions to complete the installation.

Step 2: Enable WSL (Windows Subsystem for Linux)

  1. Open PowerShell as an administrator.
  2. Run the following command to enable WSL:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enter fullscreen mode Exit fullscreen mode

Step 3: Install Ubuntu 20.04 Distribution

  1. Open Microsoft Store and search for "Linux".
  2. Select the Ubuntu 20.04 distribution and click the "Get" button to install it.
  3. Once installed, click the "Launch" button to start Ubuntu 20.04.

Step 4: Pull Ubuntu 20.04 Image

Open PowerShell or Command Prompt and run the following command to pull the Ubuntu 20.04 image from Docker Hub:

docker pull ubuntu:20.04
Enter fullscreen mode Exit fullscreen mode

Step 5: Run Ubuntu 20.04 Container

Run the following command to start a Docker container based on the Ubuntu 20.04 image:

docker run -it --name my-ubuntu-container ubuntu:20.04
Enter fullscreen mode Exit fullscreen mode

Step 6: Restarting the Container

To restart the container named "my-ubuntu-container" later, use the following command:

docker start my-ubuntu-container
Enter fullscreen mode Exit fullscreen mode

Conclusion

Setting up a local development environment using Docker on both Mac and Windows platforms is straightforward and provides a consistent environment for development. By following the steps outlined in this article, you can quickly create and manage Docker containers for your development needs. Whether you're working on a Mac or Windows machine, Docker simplifies the process of setting up and managing development environments. Happy coding!

💖 💪 🙅 🚩
brownian77
brownian77

Posted on March 8, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related