Day 17 : Docker Project for DevOps Engineers.
A Dockerfile serves as a blueprint for creating Docker images, allowing us to automate the image-building process. By encapsulating each step within the Dockerfile, we can streamline the creation of our images with a single command. Here are some essential commands commonly utilized in a Dockerfile:
__________________________________________________________________________________
Tasks:
Python application cloned: https://github.com/mosad2/docker-projects-.git
The steps to run the application locally are explained in the above link. I am just creating the dockerfile for the same steps.
Dockerfile:
FROM python:3.9-slim-buster
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app.py .
EXPOSE 5000
CMD ["python", "app.py"]
2. Build the image using the Dockerfile and run the container.
Build the image -
docker build . -t mosad7/myqouta-app
领英推荐
Run the Container -
3. Verify that the application is working as expected by accessing it in a web browser.
4. Push the image to a public or private repository (e.g. Docker Hub ).
Firstly, I renamed the image to push in my docker hub repo.
sudo docker tag old:tag new:tag
Now, while pushing I got access denied so I first logged in and then pushed the image.
sudo docker login
sudo docker push imagename
The image is successfully pushed.