Day 17 Task: Docker Project for DevOps Engineers.
Dockerfile:
FROM 🌐:
RUN 🛠️:
COPY 📦:
ENV 🌈:
EXPOSE 🚪:
CMD 🚀:
ENTRYPOINT 🎭:
Sets the main act for your creation.
Similar to CMD, but can be modified for a grand entrance.
WORKDIR 📂:
Tasks:
1. Create a Dockerfile:
Start by creating a Dockerfile to encapsulate your web app. For instance, let's consider a Python app:
FROM python:3
WORKDIR /data
RUN pip install django==3.2
COPY . .
RUN python manage.py migrate
EXPOSE 8002
CMD ["python","manage.py","runserver","0.0.0.0:8002"]
Recommended by LinkedIn
Step 2: Build the Docker Image
Open a terminal, navigate to the directory containing your Dockerfile, and run:
sudo docker build -t your-image-name:tag .
Step 3: Run the Container
After building the image, run the container:
sudo docker run -d -p 8002:8002 your-image-name:tag
Step 4: Verify in a Web Browser
Open your web browser and access the application at http://localhost:8002. Ensure everything works as expected.
Step 5: Push Image to Docker Hub
Assuming you have a Docker Hub account:
Login to Docker Hub using:
sudo docker login
Tag your image:
sudo docker tag your-image-name:tag your-dockerhub-username/your-image-name:tag
Push to Docker Hub:
sudo docker push your-dockerhub-username/your-image-name:tag
Conclusion
Congratulations! You've successfully Dockerized a web application. The container is running smoothly, and your image is securely stored on Docker Hub for easy deployment. 🎉
Shubham Londhe #90daysofdevops #docker #DevOps #DockerMagic #Containerization #ContainerMagic #DevOpsJourney 🚀🐳