Alian hub - Docker Setup Guide
Alian hub - Docker Setup Guide
This document provides all the steps required to set up, build, and run a Docker container for Alian hub.
Prerequisites
Docker: Make sure Docker is installed on your machine. Download Docker here.
Setup Instructions
1. Configure Environment Variables
Note: If you have already configured the environment variables and set up the necessary files, you can skip this step.
Environment Variables Setup
To manage environment variables, follow the steps below to create and configure .env
files in the necessary directories. Each part of the application (root, admin, and frontend) requires a separate .env
file to store its specific environment variables.
Note: Before this Please check .env.example file in root directory.
Steps
Root Directory
Create a
.env
file at the root level of the project (/.env
).This file will contain environment variables used by the main server.
Example:
Admin Directory
Inside the admin directory, create an .env file (/admin/.env).
Use this file to specify environment variables needed by the admin portal.
Frontend Directory
Inside the frontend directory, create an .env file (/frontend/.env).
Use this file to specify environment variables needed by the frontend portal.
3. Build the Docker Image
Run the following command to build the Docker image, loading environment variables from the .env
file:
Replace your-image-name
with your desired image name.
4. Run the Docker Container
Once the image is built, you can start the Docker container using the following command:
This command will:
Run the container in detached mode (
-d
)Map port 4000 of the container to port 4000 on the host (
-p 4000:4000
)Name the container as specified in
your-container-name
Replace your-container-name
and your-image-name
with your preferred container and image names, respectively.
5. Verify the Container
To check if the container is running correctly, use the following command:
You should see your container in the list. To view logs and troubleshoot, use:
6. Stop and Remove the Container (Optional)
When you're done, stop and remove the container:
Docker with Docker compose
You can change container and image name in docker-compose.yml file.
To build image and run container:
To stop the containers:
To rebuild the image:
To check the status of the running containers:
Summary of Commands
Here's a quick summary of the key commands:
That's it! You now have a full guide for setting up, building, and running your Docker container for Alian hub.
Docker Container and Image Management
After building your Docker image and running your container, you might want to stop and remove them. Below are the steps to do so.
1. Stop and Remove the Running Docker Container
To stop a running container, use the following command:
For example:
Once the container is stopped, you can remove it using the command:
For example:
If you want to stop and remove the container in one command, you can do:
2. Remove the Docker Image
To remove a Docker image after it has been built, use the following command:
For example:
If you have multiple tags or versions of an image, you might want to remove them all. You can use the -f
(force) flag to force the removal of the image even if there are existing containers associated with it.
3. List All Containers and Images
To check which containers and images are currently available on your system, use the following commands:
List all containers (including stopped ones):
List all images:
Example
Stop and remove the container:
Remove the Docker image:
Resources
https://docs.docker.com/reference/cli/docker
https://docs.docker.com/reference/cli/docker/compose
Last updated