Introduction:
Docker has revolutionized the way applications are developed, deployed, and managed. It allows developers to package applications and their dependencies into containers, ensuring consistency across different environments.
Now let’s explore how to install Docker on different operating systems.
Amazon Linux 2:
If you’re using Amazon Linux 2 as your operating system, this guide will walk you through the process of installing Docker so you can harness the power of containerization for your projects.
Prerequisites:
Before you begin, make sure you have the following:
- An Amazon Linux 2 instance (either on Amazon EC2 or a local machine)
- Administrative privileges (Sudo or root access)
-
Step 1: Update Package Repositories
- Open a terminal or SSH into your Amazon Linux 2 instance.
- The first thing you want to do is ensure your package repositories are up-to-date. Run the following command:
#sudo yum update -y
Step 2: Search for the Docker package
#sudo yum search docker
Step 3: Get version information
#sudo yum info docker
Step 4: Install Required Dependencies
- Docker requires some packages to be installed on your system.
- Use the following command to install the necessary dependencies:
#sudo yum install -y docker
Step 5: Start and Enable Docker
- Now that Docker is installed, you need to start the Docker service and enable it to start automatically on boot.
- Run the following commands:
#sudo systemctl start docker
#sudo systemctl enable docker
Step 6: Verify Docker Installation
- To ensure that Docker is running and functioning correctly, you can run a simple test by executing the following command:
#sudo docker --version
- This should display the version of Docker that you’ve installed, confirming that the installation was successful.
Step 7: Allowing Docker Commands Without sudo (Optional) By default
- To add your user to the “docker” group, use the following command:
#sudo usermod -aG docker $USER
- Remember that you’ll need to log out and log back in for the group changes to take effect.
Step 8: Finding status
- Get the Docker service status on your AMI instance, and run.
#sudo systemctl status docker.service
Step 9: Test a Docker Container
- To verify that Docker is functioning correctly and to get hands-on experience with containers, you can pull and run a sample container.
- For example, you can run the official “hello-world” container:
#docker run hello-world
- This command will pull the “hello-world” image from the Docker Hub and run it as a container.
- If everything is set up properly, you’ll see a message confirming the successful installation.
Windows:
Installing Docker on Windows is a straightforward process that opens the door to seamless application development and deployment. In this guide, we’ll walk you through the steps to install Docker on your Windows machine.
Step 1: Check System Requirements
Before diving into the installation process, ensure your system meets the minimum requirements:
- Windows 10 64-bit: Pro, Enterprise, or Education editions.
- A compatible processor with Second Level Address Translation (SLAT).
- Virtualization technology must be enabled in BIOS/UEFI settings.
- At least 4GB of RAM (8GB or more is recommended).
- Hyper-V and containers must be enabled in the Windows Features settings.
Step 2: Download Docker Desktop
To start the installation, you need to download Docker Desktop, which includes everything you need to run Docker containers on Windows. Follow these steps:
- Open your preferred web browser and navigate to the Docker Desktop download page (https://www.docker.com/products/docker-desktop ).
- Click on the “Get Docker Desktop for Windows” button to start the download.
- Once the download is complete, locate the installer file (usually named “Docker Desktop Installer.exe”) and run it.
Step 3: Installation Process
The installation process is quite straightforward.
- Double-click the installer file to launch the installation wizard.
- If prompted, grant the installer the necessary permissions for the installer to make changes to your system.
- The installer will guide you through the setup process, including configuring Docker settings.
- You can choose to use Windows containers, Linux containers, or both.
- During the installation, Docker Desktop will require a restart of your computer.
- Make sure to save any ongoing work before proceeding.
Step 4: Verify Installation
Once your computer has restarted, you can verify the successful installation of Docker Desktop:
- Look for the Docker icon in your system tray (usually located at the bottom-right corner of your screen).
- It may take a few moments to initialize.
- When Docker is ready, the icon will turn from gray to the Docker whale logo.
- Right-click on the Docker icon and select “Settings” to explore and configure Docker Desktop preferences.
Step 5: Test Docker Installation
Now that Docker is installed, let’s run a simple test to ensure it’s working as expected:
- Open the Command Prompt or PowerShell.
- Type the following command and press Enter:
#docker --version
- This command will display the Docker version if the installation is successful.
MacOS:
Step 1: Check System Requirements
- Before you begin, ensure that your macOS version meets the requirements.
- Docker Desktop for macOS requires a 64-bit Intel-based Mac running macOS Yosemite 10.10.3 or later, with at least 4 GB of RAM.
Step 2: Download Docker Desktop
- Open your preferred web browser and navigate to the official Docker website: https://www.docker.com/products/docker-desktop
- Click on the “Get Docker Desktop for Mac” button to start the download.
Step 3: Install Docker Desktop
- Once the download is complete, locate the downloaded Docker Desktop package (usually in your Downloads folder).
- Double-click the package file to start the installation process.
- Drag and drop the Docker icon into the Applications folder to complete the installation.
Step 4: Launch Docker Desktop
- Open the Applications folder and locate the Docker icon.
- Double-click the Docker icon to launch the Docker Desktop.
- You might be prompted to grant permission for Docker to change your system.
- Docker Desktop will start up, and a whale icon will appear in your system tray, indicating that Docker is running.
Step 5: Verify Installation
To ensure Docker is installed correctly, you can run a simple test command.
- Open a terminal window (you can find it in Applications > Utilities or use Spotlight search).
- Type the following command and press Enter:
#docker --version
Conclusion:
Congratulations on installing Docker! Whether on Amazon Linux 2, Windows, or macOS, you’ve opened doors to efficient development and deployment. Docker’s containerization simplifies managing applications and dependencies for consistent experiences across environments.
Explore Docker further—customize images, manage containers, and deploy multi-container apps. Enjoy the versatility and power Docker brings to your projects. Happy containerizing!