Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Building Your First Container with a HelloWorld Image using Docker CLI

    Building Your First Container with a HelloWorld Image using Docker CLI

    December 7, 2024

    1. What is Docker CLI?

    Docker is an open-source platform, and it is used to containerize the application. It packages the application along with the dependencies into the containers, which is easier to deploy.

    Docker CLI is a command-line interface for Docker that helps to build images and start and stop the containers from the command line.

    2. Docker CLI commands help

    a. Open the terminal or PowerShell.

    b. Run the command ‘docker –help’ to get help on Docker CLI commands.



    Fig 1: Docker Help

    c. Run the command ‘docker network –help’ to get the command-specific help.



    Fig 2: Docker command help

    d. Run the command ‘docker network create –help’ to know the options for the specific command method.



    Fig 3: Docker command method options help

    3. Create a docker container from CLI (Method 1):

    3.1. Create a Docker container from ‘Hello world’ image

    a. Run the command ‘docker container create imagename’ to create a docker container from the ‘Hello world’ image.

    b. Example: docker container create hello-world:latest

    c. It will check for the hello-world image locally and start the container if it is found; otherwise, it downloads from the Docker Hub.



    Fig 4: Create Docker Container from ‘Hello world’ image

    3.2. List the Docker Containers

    a. Run the command ‘docker ps’ to list the active containers. The following images don’t show our container because it will list only the active containers.



    Fig 5: Docker ps

    b. Run the command ‘docker ps –list’ to list all the containers, both active and inactive.



    Fig 6: Docker ps all

    3.3. Start the container

    a. Run the command ‘docker start container ‘ to start the containers.

    • Example: Run the command ‘docker start container 25c8937cabb1’ to start our container.


    Fig 7: Docker container start by container id

    b. Run the command ‘docker ps -all’ to list all the containers again.



    Fig 8: Docker container start and exit

    c. You can see the container status, which created and exited about a minute ago message in the screenshot.

    3.4. Docker Logs

    a. Run the command ‘docker logs ‘ to view the logs of the container.

    b. Example: Run the command ‘docker logs 25c8937cabb1’ to view our container logs.



    Fig 9: Docker container logs

    c. You can also attach the logs while starting the container.

    d. Run the command ‘docker container start –attach containerid’ to attach the logs while starting the container.

    e. Example: Run the command ‘docker container start –attach 25c8937cabb1’ to attach the logs while starting our container.



    Fig 10: Docker container attach logs

    f. We can start the same container multiple times because the containers won’t be deleted and can be started anytime.

    4. Create a docker container from CLI (Method 2):

    4.1. Create a docker container from ‘Hello world’ image

    a. Run the command ‘docker run ImageName’ to create a container from the given image.

    b. Example: Run the command ‘docker run hello-world:latest’ to create a container and run the image for the ‘Hello world’ latest image.



    Fig 11: Docker run

    4.2 Docker run

    a. Basically, the following actions will happen with docker run:
    docker run = docker container create + start + attach

    b. Run the command ‘docker ps –all’ to list all the docker containers to view the newly created container.



    Fig 12: Docker ps all

    c. Run the command ‘docker logs ‘ to view the Docker container logs.

    d. Run the command ‘docker logs 3380c26f2f2f’ to view the newly created Docker container logs.



    Fig 13: Docker logs by container id

    Source: Read More

    Facebook Twitter Reddit Email Copy Link
    Previous Article40+ Best Logo Templates for Gamers
    Next Article C# Advent: No one loves the .NET Core name anymore

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 16, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-2305 – Apache Linux Path Traversal Vulnerability

    May 16, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Is it possible to make a jar file using Selenium java and Eclipse and run that file on any machine for the testing

    Development

    Atlas Vector Search erneut zur beliebtesten Vektordatenbank gewählt

    Databases

    Overwatch 2’s Gundam Wing crossover event has been fully revealed with a new trailer

    News & Updates

    Cloud gaming files reveal the Sebile and Actium Duet Xbox controllers

    Operating Systems
    GetResponse

    Highlights

    How to use a PHP API Generator Package to Quickly Generate PHP API Applications with Web Pages to Manipulate Laravel Model Objects using CRUD Interfaces

    May 2, 2024

    How to use a PHP API Generator Package to Quickly Generate PHP API Applications with…

    This Intel-based mini PC is ideal for everyday tasks, media centers, or tech enthusiast projects — You can grab it at a massive discount with this coupon code

    December 20, 2024

    Choosing Between callTestCase and Custom Keywords in Katalon Studio

    August 21, 2024

    India’s Average Data Breach Cost $2.18 Million in 2023: RBI Cybersecurity Report

    July 29, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.