This project demonstrates how to create a Docker image for an application and run it as a Docker container. The project includes a Dockerfile which contains all the necessary instructions to build the image.
- Docker installed on your machine
- Follow the Docker official documentation for Docker Installation.
Clone the project to any directory where you do development work.
git clone https://github.com/praks7v/BloggersUnity.git
cd BloggersUnity
To build the Docker image, make sure the Dockerfile at right location and run the following command:
docker build . -t bloggersunity:latest -f docker/DockerfileTo build the Docker image using docker compose:
docker compose -f docker/docker-compose.yaml build
This command builds the Docker image and tags it as latest.
To run the Docker container, use the following command:
docker run -p 8000:8000 bloggersunity:latestTo run the Docker container using docker compose, use the following command:
docker compose -f docker/docker-compose.yaml up
This command maps port 8000 in the container to port 8000 on your host machine. You can access the application by navigating to http://localhost:8000.
To push images to Docker Hub, you need to authenticate with your Docker Hub account. Use the docker login command:
docker loginTo share your Docker image, you can push it to Docker Hub. First, tag your image with your Docker Hub repository name:
docker tag bloggersunity <your-dockerhub-username>/bloggersunity:latestThen, push the image to Docker Hub:
docker push <your-dockerhub-username>/bloggersunity:latestIf you want to pull and run the Docker image from Docker Hub, use the following commands:
docker pull <your-dockerhub-username>/bloggersunity:latest
docker run -p 8000:8000 <your-dockerhub-username>/bloggersunity:latest- Build an image:
docker build -t myapp . - Run a container:
docker run -p 4000:80 myapp
- Tag an image:
docker tag myapp your-dockerhub-username/myapp
- Push an image to Docker Hub:
docker push your-dockerhub-username/myapp
- Pull an image from Docker Hub:
docker pull your-dockerhub-username/myapp
- List Docker images:
docker images
- List running containers:
docker ps
- Stop a running container:
docker stop <container_id>
- Remove a Docker image:
docker rmi myapp
- Ensure Docker is installed and running on your machine.
- Check that the Dockerfile and application files are correctly set up.
- Use
docker logs <container_id>to view the logs if the container is not running as expected.
Feel free to submit pull requests or open issues if you encounter any problems or have suggestions for improvements.
This project is licensed under the MIT License.