Skip to main content

Command Palette

Search for a command to run...

๐Ÿณ๐Ÿ› ๏ธDay 17: Docker Project for DevOps Engineers

Published
โ€ข2 min read
๐Ÿณ๐Ÿ› ๏ธDay 17: Docker Project for DevOps Engineers
S

๐ŸŒฑ Aspiring Fresher with Big Dreams! ๐Ÿš€

Hey there! ๐Ÿ‘‹ I'm Sushil Pawar, a fresh face eager to embark on a journey of greatness. ๐ŸŒŸ Committed to learning, sharing thoughts, and growing together. ๐Ÿ“š๐Ÿ’ฌ

๐Ÿณ๐Ÿ“ฆ What is Dockerfile??

A Dockerfile is a text file that contains a set of instructions for building a Docker image.

It selects the base image, sets up the environment, installs dependencies, and explains how the application should run within a Docker container.

๐Ÿ๐ŸณCreating a Docker Image for a Simple Python Web Application:

๐ŸพStep 1: Create a Dockerfile for a simple web application (e.g. a Python app)

# Get a base image with python 3.7
FROM python:3.8-slim

# Set the workding directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . .

# Install all the required dependencies specified in requirements.txt
RUN pip install -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Run the python app
CMD ["python","app.py"]

๐ŸพStep 2: Build the image using the Dockerfile, and execute the following command in the same directory as the Dockerfile

docker build . -t python:latest

๐ŸพStep 3: Run the container

docker run -d -p 80:80 python:latest

๐ŸพStep 4: Verify that the application works as expected by accessing it in a web browser at http://localhost:80

๐ŸพStep 5: Push the image to a public or private repository (e.g. Docker Hub)

docker push <image:tag-name>

Note:

  • Make sure you're logged into Docker Hub before using the docker push command.

๐Ÿ“š Feel free to use these commands to manage your Docker images! ๐Ÿณ

Happy Coding :) ๐Ÿ™Œโšก

โœ… Feel free to reach out if you have any questions. I'm delighted to help! ๐Ÿ˜Š

๐Ÿค Let's Connect..!

๐Ÿ”— LinkedIn

๐Ÿ”— Twitter

๐Ÿ”— GitHub

โ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธโ˜€๏ธ