Sign inSign up

stacksimplify/mynginx

By stacksimplify

Updated almost 2 years ago

Nginx Docker Image

Image
0

1.9K

stacksimplify/mynginx repository overview

Pull Docker Image from Docker Hub and Run it

Step-01: Introduction

  1. Pull Docker images
  2. Run Docker containers
  3. Start and stop Docker containers
  4. Remove Docker images
  5. IMPORTANT NOTE: Docker Hub Sign-in is not needed for downloading public images. In this case, the Docker Image stacksimplify/mynginx is public and does not require authentication.

Step-02: Pull Docker Image from Docker Hub

# List Docker images
docker images

# Pull Docker image from Docker Hub
docker pull stacksimplify/mynginx:v1
# Or use GitHub Packages
docker pull ghcr.io/stacksimplify/mynginx:v1

# List Docker Images
docker images

Important Note:

  1. Sometimes we hit Docker image pull limits for Docker Hub.
  2. We maintain the same Docker image in GitHub Packages, where there are no download limits.
  3. You can pull the same Docker image from either Docker Hub or GitHub Packages.

Step-03: Run the downloaded Docker Image & Access the Application

  • Copy the docker image name from Docker Hub or GitHub Packages.
  • HOST_PORT: The port number on your host machine where you want to receive traffic (e.g., 8080).
  • CONTAINER_PORT: The port number within the container that's listening for connections (e.g., 80).
# Run Docker Container
docker run --name <CONTAINER-NAME> -p <HOST_PORT>:<CONTAINER_PORT> -d <IMAGE_NAME>:<TAG>
docker run --name myapp1 -p 8080:80 -d stacksimplify/mynginx:v1
# Or
docker run --name myapp1 -p 8080:80 -d ghcr.io/stacksimplify/mynginx:v1

Access Application:
http://localhost:8080/

Step-04: List Running Docker Containers

# List only running containers
docker ps

# List all containers (including stopped)
docker ps -a

# List only container IDs
docker ps -q

Step-05: Connect to Docker Container Terminal

You can connect to the terminal of a running container to inspect or debug it:

# Connect to Container using Terminal
docker exec -it <container-name> /bin/sh
docker exec -it myapp1 /bin/sh

# Commands inside container
bash
ls
hostname
exit

# Execute a command in a running container
docker exec -it myapp1 ls
docker exec -it myapp1 hostname 
docker exec -it myapp1 printenv
docker exec -it myapp1 df -h

Step-06: Docker Container Stop, Start

# Stop Container
docker stop <container-name>
docker stop myapp1
curl http://localhost:8080 # To test if the app is down

# Start Container
docker start <container-name>
docker start myapp1
curl http://localhost:8080 # To test if the app is back up

Step-07: Stop and Remove Docker Container

# Stop containers
docker stop <container-name> 
docker stop myapp1

# Remove Containers
docker rm <container-name>
docker rm myapp1

# Stop and remove container in one step
docker rm -f myapp1

Step-08: Remove Docker Image

# List Docker Images
docker images

# Remove Docker Image with Image ID
docker rmi <image-id>

# Remove Docker Image with Docker Image Name and Tag
docker rmi <IMAGE-NAME>:<IMAGE-TAG>

Tag summary

Content type

Image

Digest

sha256:b9ca7a9e4

Size

67.7 MB

Last updated

almost 2 years ago

docker pull stacksimplify/mynginx:v4