for Beginners
DevOps is the practice of operations and development engineers participating together in the entire service lifecycle, from design through the development process to production support.
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package
Running your first container
sudo systemctl start docker
# This command will start your docker deamon
docker run hello-world
# This command will run a hello-world container
docker info
# This command will give your all information about
# Your docker installation and evironment
Alpine is a micro os with 4MB size it's suitable for tests.we will execute some command inside it.
docker pull alpine:latest
docker run -it alpine sh
# run : will create and run a container from the
# alpine image
# -it : using the interactive mode to execute commands
# on the container
# sh : is the default shell like bash, zsh ..
#inside the container run these commands :
# - cat /etc/os-release
# - apk add git : install a git package
# - touch file.txt
#you can execute what you want !
We will run a simple server with flask in a docker container, first write the code.
#import required dependencies
from flask import Flask
#create an instance of the flask object
app = Flask(__name__)
#create a home route
@app.route("/")
def hello():
return "Hello My Name is Hatem"
#the main context
if __name__ == "__main__":
#run the app on port 8080 and localhost
app.run(host="0.0.0.0", port=8080)
it is a set of instructions that allow us to create the image.
# use python as a base image that is needed
# to run any python app
FROM python:latest
# define a work directory
WORKDIR /app
# copy the req.txt to the app folder in the image
COPY requirements.txt .
# install all packages existed inside te file
RUN pip install -r requirements.txt
# copy the app.y to /app
COPY app.py .
# execute the python script when running the container
CMD python app.py