Skip to content

Visitha2001/User-Auth-Docker

Repository files navigation


User CRUD Application

This repository contains the source code and instructions for running a User CRUD Application using Docker. The application listens on port 3000 by default but can be mapped to any host port during runtime.


Table of Contents


Prerequisites

Before you begin, ensure that the following tools are installed on your system:

  • Docker: Install Docker from the official website.
  • Git (optional): If you need to clone this repository.

Verify your Docker installation by running:

docker --version

Building the Docker Image

To build the Docker image for the application, follow these steps:

  1. Navigate to the root directory of the project where the Dockerfile is located.

  2. Run the following command to build the image:

    docker build -t visitha/user-crud-v1.0.0 .
    • -t visitha/user-crud-v1.0.0: Tags the image with the name visitha/user-crud-v1.0.0.
    • .: Specifies the current directory as the build context.
  3. Verify that the image has been built successfully:

    docker images

    You should see an entry for visitha/user-crud-v1.0.0.


Running the Docker Container

Once the image is built, you can run the container using the following command:

Default Port Mapping

By default, the application listens on port 3000. To map it to the same port on your host machine:

docker run -p 3000:3000 visitha/user-crud-v1.0.0

Custom Port Mapping

If you want to map the application's port 3000 to a different port (e.g., 3001) on your host machine:

docker run -p 3001:3000 visitha/user-crud-v1.0.0

Alternatively, you can use the image ID instead of the tag:

docker run -p 3001:3000 <imageID>

Replace <imageID> with the actual image ID obtained from docker images.


Accessing the Application

After starting the container, the application will be accessible via the specified host port. For example:

  • If you used the default mapping (3000:3000), access the app at:

    http://localhost:3000
    
  • If you used a custom mapping (3001:3000), access the app at:

    http://localhost:3001
    

Stopping the Container

To stop the running container:

  1. List all running containers:

    docker ps
  2. Identify the container ID or name of your application.

  3. Stop the container using:

    docker stop <containerID_or_name>

Additional Notes

  • Environment Variables: If your application requires environment variables, you can pass them using the -e flag:

    docker run -p 3001:3000 -e ENV_VAR_NAME=value visitha/user-crud-v1.0.0
  • Persistent Data: If your application uses a database or requires persistent storage, consider using Docker volumes:

    docker run -p 3001:3000 -v /host/path:/container/path visitha/user-crud-v1.0.0
  • Logs: To view the logs of a running container:

    docker logs <containerID_or_name>

About

Docker Implementation within a nextJS application.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published