Docker - DrAlzahraniProjects/csusb_fall2024_cse6550_team2 GitHub Wiki
1. Installation
Docker Setup on macOS
-
Download Docker Desktop
- Get it from the official Docker Desktop page.
-
Install Docker Desktop
- Open the
.dmg
file, drag Docker to the Applications folder, and follow the setup instructions.
- Open the
-
Verify Installation
- Run the following command:
docker --version
- Run the following command:
2. Configuration
Docker Daemon Settings
- Access Preferences > Docker Engine in Docker Desktop to edit settings like CPU, memory, and disk allocation.
Useful Docker Commands:
-
Start Docker Daemon (if not automatically running):
open -a Docker
-
Check Docker Daemon Status:
docker info
3. Implementation
Role of Docker in My Project
-
Create Dockerfile
This is the Dockerfile used in the project:FROM python:3.10-slim WORKDIR /app COPY requirements.txt /app/requirements.txt RUN pip install -r requirements.txt COPY . /app ENTRYPOINT ["python"] CMD ["app.py"]
- Build Docker Image
Use the following command to build the Docker image for the app:docker build -t team2-app .
- Run Docker Container
To run the container:
This exposes the app on port 5000.docker run -d -p 5000:5000 team2-app
- Container is running in the docker app
- Application is running on http://localhost:5002/team2/
4. Usage
Common Docker Commands in Project
-
List Running Containers:
docker ps
-
Stop a Container:
docker stop <container_id>
-
Remove a Container:
docker rm <container_id>
-
Check Logs of a Container:
docker logs <container_id>
5. Troubleshooting
Common Issues Faced:
-
Docker Daemon Not Running
Solution: Restart Docker Desktop or run:open -a Docker
-
Port Already in Use
Solution: Use a different port when running:docker run -d -p 5001:5000 team2-app
-
Permission Errors
Solution: Adjust user permissions with:docker run --user $(id -u):$(id -g) -v $(pwd):/app team2-app
-
Increase Resources
Solution: Adjust memory and CPU in Preferences > Resources.