Skip to content

Latest commit

 

History

History
104 lines (67 loc) · 2.8 KB

docker-setup.md

File metadata and controls

104 lines (67 loc) · 2.8 KB

Backend Docker Setup for PictoPy

This guide provides step-by-step instructions for building and running the PictoPy backend using Docker.

Table of Contents

  1. Prerequisites
  2. Building the Docker Image
  3. Running the Docker Container
  4. Verifying the Container
  5. Accessing the Application
  6. Stopping the Container
  7. Troubleshooting

Prerequisites

Before you begin, ensure you have the Docker installed on your machine

  • Verify the installation by running:
    docker --version

Building the Docker Image

  1. Open a terminal and navigate to your project's root directory.

  2. Go to Backend directory

    cd backend
  3. Run the following command to build the Docker image, replacing <image_name> with your desired image name:

    docker build -t <image_name> .
  4. Wait for the build process to complete. This may take a few minutes depending on your internet speed and system performance.

Running the Docker Container

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

docker run -d -p 8000:8000 --name <container_name>  <image_name>
  • -d: Runs the container in detached mode (in the background).
  • -p 8000:8000: Maps port 8000 on the host to port 8000 in the container.
  • --name <container_name>: Names the container for easier management.
  • <image_name>: Specifies the image to use (the one we just built).

Verifying the Container

To check if the container is running:

docker ps

You should see an entry for <container_name> with the status Up.

Accessing the Application

Open a web browser or frontend to access the application at:

http://localhost:8000

Stopping the Container

If you need to stop the container:

docker kill <container_id>

Troubleshooting

  1. Port already in use: If you get an error saying the port is already in use, you can either:

    • Stop the process using port 8000, or
    • Change the port mapping in the docker run command (e.g., -p 8001:8000)
  2. Container exits immediately: Check the container logs:

    docker logs <container_name>
  3. Permission issues: Ensure that run.sh has execute permissions(for linux only):

    chmod +x run.sh

    Then rebuild the Docker image.

Remember to rebuild your Docker image (docker build -t <image_name> .) after making any changes to your application or Dockerfile.

For more advanced Docker usage , view the Docker documentation.