How to create a Docker container in Docker Desktop

Docker is a SaaS (software as a service) application that uses OS virtualization to construct containers. These containers are separate pieces of software that come complete with all the files required to execute the corresponding application, including code, system tools, system libraries, and installed bespoke applications. Users who want to deploy and test numerous separate systems simultaneously can do so with the help of Docker containers, which offer a portable and lightweight experience.

Moreover, Docker can be used through two pathways. The first is through our machine terminal. To learn more about installing that, we can go to this Answer. Second, we can install the official Docker Desktop application. In this answer, we will follow the latter and set up a Docker container through the application.

Installation

Now that we know what Docker is and which path to create our container, we will follow the given sets to install our Docker Desktop application.

  1. We will first head to the official Docker website to download the application for our respected operating system.

  2. Afterward, we will open our application. We can sign in to our Docker Hub and/or download the necessary extensions here.

Creating containers

We can create our Docker containers by installing our Docker Desktop application. Let us follow these steps to create our first container.

  1. In the search bar, we can search for any base image we want for the Docker Hub directory or our private directory.

Search bar
Search bar
  1. For this example, we will create a "Ubuntu" image. First, we will locate our desired image and then pull and run it with the desired version. It will then give us some optional settings we can fill in per our needs.

Optional settings
Optional settings
  1. Another way to run our selected image is to use the terminal i.e., the command line interface. To do so, we need to run the command docker run <image_name>. For our example, we will use the command given below.

docker run ubuntu
Ubuntu command
  1. We can open our container to get a better look at what is happening within.

Container details
Container details
  1. As we can see from the containers tab, we created two containers from the Ubuntu base image. Moreover, we can also see their details given below.

Container view
Container view

Conclusion

Creating containers is an important process that can help us to manage multiple independent operating systems with different processes running within. Moreover, the Docker Desktop application makes the experience easier for beginners as it removes the command line interface commands and adds a simplistic user interface to streamline the process.

Note: Explore more answers related to Docker:

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved