📝 docs(_details): about docker

This commit is contained in:
Eshan Roy
2024-11-30 20:48:00 +05:30
parent 34d5118e25
commit 48c8b7b9eb
2 changed files with 47 additions and 4 deletions

View File

@@ -15,19 +15,19 @@ jobs:
steps: steps:
# Checkout repository # Checkout repository
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
# Set up QEMU for multi-architecture builds # Set up QEMU for multi-architecture builds
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v3
# Set up Docker Buildx for advanced builds (multi-arch, caching) # Set up Docker Buildx for advanced builds (multi-arch, caching)
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
# Login to Docker Hub using secrets for security # Login to Docker Hub using secrets for security
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}

43
readme.md Normal file
View File

@@ -0,0 +1,43 @@
# INTRODUCTION TO DOCKER
A **Dockerfile** is a text file that contains a set of instructions used to automate the creation of a Docker image. It defines the environment, software dependencies, configurations, and commands that will be executed inside a container when it is built and run. Dockerfiles are used by Docker to build images, which can then be used to create containers.
Here's a breakdown of common Dockerfile instructions:
1. **FROM**: Specifies the base image to use (e.g., `FROM ubuntu:20.04`).
2. **RUN**: Executes commands inside the image, such as installing software packages (e.g., `RUN apt-get update`).
3. **COPY**: Copies files or directories from your local filesystem to the image (e.g., `COPY . /app`).
4. **ADD**: Similar to `COPY`, but can also handle URLs and unpack compressed files.
5. **WORKDIR**: Sets the working directory for subsequent instructions (e.g., `WORKDIR /app`).
6. **CMD**: Specifies the default command to run when a container is started (e.g., `CMD ["python", "app.py"]`).
7. **EXPOSE**: Informs Docker that the container will listen on specific ports (e.g., `EXPOSE 80`).
8. **ENV**: Sets environment variables in the container (e.g., `ENV APP_ENV=production`).
9. **ENTRYPOINT**: Defines the command that will always run when the container starts, even if a different command is provided at runtime.
10. **VOLUME**: Creates a mount point for volumes, allowing data persistence (e.g., `VOLUME /data`).
### Example Dockerfile:
```dockerfile
# Use the official Python image as the base image
FROM python:3.8-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container
COPY . /app
# Install any necessary dependencies
RUN pip install -r requirements.txt
# Expose port 5000
EXPOSE 5000
# Define the default command to run the app
CMD ["python", "app.py"]
```
### Key Uses of a Dockerfile:
- **Reproducibility**: The same Dockerfile can be used to build the same environment across different systems, ensuring consistency.
- **Automation**: A Dockerfile allows you to automate the process of building an image with specific configurations and software.
- **Portability**: Once built, Docker images can be shared and run on any platform that supports Docker.
In essence, a Dockerfile is a blueprint for creating Docker images, ensuring the environment is consistent and reproducible.