At this moment there is no actual database just an in memory stub, so it won't work really. But this is to test the ID generation part.
- Pull the Official ZooKeeper Docker Image Pull the latest ZooKeeper image from Docker Hub.
docker pull zookeeper- Run the ZooKeeper Docker Container Start a ZooKeeper container from the pulled image, exposing port 2181.
docker run --name tiny-url-zookeeper --network=tinyurlnetwork -p 2181:2181 -d zookeeper- Build the Application Docker Image Navigate to the directory containing your application's Dockerfile, then build a Docker image for the application.
docker build -t tiny-url-app .- Run the Application Docker Containers Start two containers from your application's Docker image. These will connect to the ZooKeeper server using the container name as the hostname.
docker run -d --name=app-instance-1 --network=tinyurlnetwork -p 3001:3000 tiny-url-app
docker run -d --name=app-instance-2 --network=tinyurlnetwork -p 3002:3000 tiny-url-appRemember to replace tinyurlnetwork with your Docker network name, tiny-url-zookeeper with your ZooKeeper container name, and tiny-url-app with your application's Docker image name. The -p flag maps the container's port to a port on your host machine, and the -d flag runs the container in detached mode.
-
Accessing the Application With this setup, you should be able to access the two instances of your application at http://localhost:3001 and http://localhost:3002.
-
Stopping and Removing Containers To stop and remove the containers when you're done, you can use:
docker stop app-instance-1 app-instance-2 tiny-url-zookeeper
docker rm app-instance-1 app-instance-2 tiny-url-zookeeper- Removing the Docker Image If you want to remove the Docker image for your application, you can do so with:
docker rmi tiny-url-app- Integrate with a NoSQL document DB
- Better config management
- Deploy using AWS