Sign inSign up

alikumbhar/online-bike-store

By alikumbhar

•Updated 24 days ago

Image
0

47

alikumbhar/online-bike-store repository overview

Online Bike Store – Docker Image

Run the Online Bike Store application using Docker in just a few simple steps. This application uses MySQL as its database and is accessible through your browser.

šŸš€ Quick Start Guide Prerequisites Docker installed on your system. A terminal or command prompt. Ports 3306 and 8080 available. Step 1: Create a Docker Network

Create a dedicated network so the application can communicate with the MySQL database.

docker network create bike-network

If the network already exists, you can skip this step.

Step 2: Start the MySQL Database

Run the following command to start the MySQL database container:

docker run -d
--name bike-db
--restart unless-stopped
--network bike-network
--network-alias database
-e MYSQL_DATABASE=bike_shop
-e MYSQL_USER=bike_user
-e MYSQL_PASSWORD="${DB_PASSWORD:-bike_pass}"
-e MYSQL_ROOT_PASSWORD="${MYSQL_ROOT_PASSWORD:-root_pass}"
-p 3306:3306
mysql:8.0

This command automatically creates the bike-db container and initializes the bike_shop database with the application user.

Important: The default passwords are for testing only. Set your own secure passwords before deploying this application publicly.

Step 3: Pull the Application Image

Download the Online Bike Store image from Docker Hub:

docker pull alikumbhar/online-bike-store:01

Step 4: Run the Application

Start the application container with the following command:

docker run -d
--name bike-frontend
--restart unless-stopped
--network bike-network
-p 8080:80
-e DB_HOST=database
-e DB_NAME=bike_shop
-e DB_USER=bike_user
-e DB_PASSWORD="${DB_PASSWORD:-bike_pass}"
alikumbhar/online-bike-store:01

This starts the application and connects it to the MySQL database through the Docker network.

Step 5: Open the Application

Once the containers are running, open your browser and visit:

http://localhost:8080⁠

If Docker is running on a remote server, replace localhost with your server's IP address.

⚔ Quick Installation (Copy and Paste)

If you want to install everything at once, run the following commands in a Bash-compatible terminal:

docker network create bike-network 2>/dev/null || true

docker run -d
--name bike-db
--restart unless-stopped
--network bike-network
--network-alias database
-e MYSQL_DATABASE=bike_shop
-e MYSQL_USER=bike_user
-e MYSQL_PASSWORD="${DB_PASSWORD:-bike_pass}"
-e MYSQL_ROOT_PASSWORD="${MYSQL_ROOT_PASSWORD:-root_pass}"
-p 3306:3306
mysql:8.0

docker pull alikumbhar/online-bike-store:01

docker run -d
--name bike-frontend
--restart unless-stopped
--network bike-network
-p 8080:80
-e DB_HOST=database
-e DB_NAME=bike_shop
-e DB_USER=bike_user
-e DB_PASSWORD="${DB_PASSWORD:-bike_pass}"
alikumbhar/online-bike-store:01

After the commands finish, visit http://localhost:8080⁠ to access the application.

Note: The quick-install commands assume that the container names are not already in use. MySQL may also need a short time to initialize before the application can connect. If the application starts before MySQL is ready, check the logs and restart the application if necessary.

šŸ› ļø Useful Docker Commands

Check running containers:

docker ps

View application logs:

docker logs bike-frontend

View database logs:

docker logs bike-db

Stop the application:

docker stop bike-frontend

Stop the database:

docker stop bike-db

Restart the application:

docker restart bike-frontend

šŸ”§ Configuration Variable Description Default DB_HOST MySQL hostname on the Docker network database DB_NAME Database name bike_shop DB_USER Database username bike_user DB_PASSWORD Database user's password bike_pass MYSQL_ROOT_PASSWORD MySQL root password root_pass šŸ“¦ Docker Image

Docker Hub: alikumbhar/online-bike-store:01

Application URL: http://localhost:8080⁠

Enjoy running the Online Bike Store with Docker! šŸļø

Tag summary

Content type

Image

Digest

sha256:a935eb0f3…

Size

175.1 MB

Last updated

24 days ago

docker pull alikumbhar/online-bike-store:01