List of Topics:
Location Research Breakthrough Possible @S-Logix pro@slogix.in

Office Address

Social List

How to Create a Simple Docker Image from a Dockerfile and Run It?

Docker

Condition for Create a Simple Docker Image from a Dockerfile and Run It

  • Description:
    This task helps you to create a Docker image using a basic Dockerfile that prints “Hello Docker!” when run. This demonstrates the process of creating, building, and running a custom Docker image.

Steps

  •  Step 1 — Create a Project Folder
     Description: Make a folder to store your Dockerfile and related files.
     Command:
    mkdir docker-demo
    cd docker-demo
  •  Step 2 — Create Dockerfile
     Description: Create a Dockerfile with instructions for the image.
     Command:
    nano Dockerfile
     Dockerfile content to paste inside nano:
    FROM alpine
    CMD ["echo", "Hello Docker!"]
     Save and exit: CTRL+O → Enter → CTRL+X
  •  Step 3 — Build Docker Image
     Description: Build the Docker image from the Dockerfile and give it a name.
     Command:
    docker build -t hello-docker .
     -t hello-docker → assigns a name to the image
     . → build from the current folder
  •  Step 4 — Run the Docker Image
     Description: Start a container using the image to see the output.
     Command:
    docker run hello-docker
  •  Step 5 — Verify Output
     Description: Check that the container prints the expected message.
     Expected Output:
    Hello Docker!
Screenshots
  • 316
  • 317
  • 318
  • 319
  • 320