Open In App

How To Use Docker Desktop To Deploy Docker Containerized Applications

Last Updated : 07 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Docker Desktop is a versatile and user-friendly tool that simplifies the deployment of Docker containerized applications on your local machine. It provides a graphical interface for managing containers, images, and volumes, making it accessible for developers and DevOps professionals. In this guide, we will walk you through the essential steps of using Docker Desktop, from installation to deploying a simple Nginx application.

What is Docker Desktop?

Docker Desktop is a lightweight virtualization platform that enables you to run containers on your local machine. Docker Containers are portable and self-contained units that encapsulate an application and its dependencies. Docker Desktop streamlines the development, testing, and deployment processes, making it an integral part of modern application development workflows.

Installation of Docker Desktop

Before we delve into deploying containerized applications, let’s get Docker Desktop installed on your machine. Follow these steps based on your operating system:

Windows Installation

Visit the Docker website and download the Docker Desktop installer for Windows. Run the installer, following the on-screen instructions. Upon installation, Docker Desktop may prompt you to enable virtualization in your system’s BIOS settings. Make sure to do this for optimal performance.

For further installation guide refer How to install Docker on Windows.

MacOS Installation

Download the Docker Desktop installer for macOS from the official Docker website. Open the downloaded package and drag the Docker icon to your Applications folder. Launch Docker Desktop from the Applications folder.

For further installation guide refer How to install Docker on MacOS.

Linux Installation

Install Docker Engine on your Linux distribution by following the official documentation. Download the Docker Desktop package for Linux from the Docker website. Install Docker Desktop by executing the provided commands in the terminal.

Getting Started with Docker Desktop

Now that Docker Desktop is installed, let’s explore the basic functionalities.

  1. Access to DockerHub: Upon launching Docker Desktop, you may be prompted to sign in with your Docker ID. If you don’t have one, you can create it for free. Logging in allows you to access Docker Hub, a cloud-based registry for Docker images.
  2. Dashboard: The Dashboard serves as the command center, providing an overview of your running containers, available images, and other essential information. It’s the first screen you see upon launching Docker Desktop.
  3. Containers: In the Containers section, you can manage your running containers. Docker Desktop allows you to start, stop, and remove containers with a simple click, making it a user-friendly way to interact with your applications.
  4. Images:The Images section displays the Docker images available on your system. You can pull images from Docker Hub, create custom images, and manage image repositories effortlessly.
  5. Docker Volumes: Volumes in Docker Desktop are where you manage persistent data storage for your containers. This is crucial for applications that require data persistence beyond the lifespan of a container.

Docker Desktop GUI

Deploying Your First Docker Container with Docker Desktop

Now that Docker Desktop is up and running, let’s deploy a basic containerized application using the GUI.

For starters, if you want to explore more. Open Docker Desktop and navigate to the “Dashboard.” Use the search bar to find an image. For example, let’s search for the official Nginx image. Click on the image to pull it to your local machine. Then Click on run button run the ubuntu, after doing this it show the status “In use” instead of unused. With the container running, open a web browser and navigate to http://localhost:8080. You should see the default Nginx welcome page, indicating a successfully deployed containerized application.

Deploying the Containerized Image

We can try other images availabe on DockerHub as per our need. But in this article, we will be focusing more on how to run a custom container.

Creating a Dockerfile

To deploy a custom application, you’ll need to create a Dockerfile. This file contains instructions for building a Docker image.

Here’s a simple Dockerfile for an Nginx application:

# Use the official Nginx image
FROM nginx:latest

# Copy your HTML files into the container
COPY ./html /usr/share/nginx/html

Building and Running the Docker Image

Open a terminal in the directory containing your Dockerfile. Build the Docker image:

docker build -t my-nginx-app .

Building the Docker Image

Run the Docker container:

docker run -d -p 8080:80 my-nginx-app

This command maps port 8080 on your host machine to port 80 on the container.

Running the Docker Container

Managing Multi-Container Applications with Docker Compose

Docker Desktop seamlessly integrates with Docker Compose, allowing you to define and manage multi-container applications using a YAML file.

Create a docker-compose.yml File

In your project directory, create a docker-compose.yml file with the following content:

version: '3'
services:
web:
image: nginx
ports:
- "8080:80"
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: mydatabase

This example defines two services: web (Nginx) and db (MySQL). It specifies port mapping for the Nginx service and sets environment variables for the MySQL service.

Run Docker Compose

On the Docker Desktop Dashboard, go to the “File” menu and select “Open Compose.” Choose your docker-compose.yml file. Docker Desktop will recognize the file and present options to build and run the defined services.

Access Your Multi-Container Application

With Docker Compose running, your multi-container application is accessible just like a single-container application. Visit http://localhost:8080 to interact with the Nginx service in this example.

Conclusion

Docker Desktop, with its user-friendly interface, brings the power of containerization to developers without the need for extensive command-line knowledge. This guide has covered the installation of Docker Desktop on Windows, macOS, and Linux, as well as an exploration of its graphical interface for deploying and managing containerized applications. By leveraging Docker Desktop’s intuitive features, developers can streamline their workflows and embrace the efficiency and portability that containerization offers in the world of modern software development.

Troubleshooting Queries of Docker Container Deployment

How To Resolve “Docker Desktop fails to start” Issue?

Try to Ensure that virtualization is enabled in your system’s BIOS and Check for conflicting softwares that might be interfering with Docker Desktop.

What Are Steps Should Be Taken When Encountered a Failure In Pulling An Image?

Fiirstly try on verifying your internet connection stability and Next check whether the pulling image exists on Docker Hub Repository or Not.

What To Do When the Port Conflict Issue Raised With Error “Port Already In Use”?

The Port Conflict Issue raise when you are trying to use already assigned and working port for other program, to resolve this try on using Other available ports. To know what are the port currently used run the following command.

netstat -tnlp

What Steps Should Be Taken When The Docker Application Is Not Accessible From The Host?

Firstly Ensure the Application binded with the correct port and verify the firewall settings on the host machine to allow traffic to the specified port.

How To TroubleShoot Slow Performance Inside a Docker Container?

Firstly check the resource allocation for the container and then inspect the container logs for errors. Check the Host Mahine respective resources. In addition try on optimizing the applications code if necessary.

Deployment Of Containers On Docker Desktop – FAQs

Can I Run Docker Desktop On Older Hardware?

Docker Desktop requires virtualization support, so check your system’s specifications. If your hardware lacks virtualization, consider using Docker Toolbox.

How Can I Share My Docker Image With Others?

Push your image to Docker Hub using the docker push command. Others can then pull and run the image.

Can I Use Docker Desktop For Production Environments?

Docker Desktop is primarily for local development. For production, consider Docker Swarm or Kubernetes.

How Do I Deploy an Application To a Docker Container?

On using Dockerfile, Defining the Appliation Environment and Dependencies then building an image from it. Finally you can use that Docker image to run a container.

Can a Docker Container Have a Desktop?

No, Docker Container are used for running applications with isolated environment they doesn’t contain graphical User Interface like a Desktop.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads