Using Python Interpreter and running Python Code on Docker Container and creating httpd service using docker
firstly your system should have docker installed then follow the steps below…
A Docker image is the blueprint of Docker containers that contains the application and everything you need to run the application. A container is a runtime instance of an image.
In this tutorial, we will explain what Dockerfile is, how to create one, and how to build a Docker image with Dockerfile.
What is Dockerfile?
A Dockerfile is a text file that contains all the commands a user could run on the command line to create an image. It includes all the instructions needed by Docker to build the image.
Docker images are made up of a series of filesystem layers representing instructions in the image’s Dockerfile that makes up an executable software application.
Create a Dockerfile
RUN dnf update
dnf install python36 -y
dnf install net-tools vim which -y
build the image
docker build -t IMAGE_NAME(to build the image)
-docker build -t myweb:v1
docker run -it --name NAME_OF_CONTAINER IMAGE_NAME
run the docker file
Configuring HTTPD Server on Docker Container
TO ACCESS THE DOCKER IN YOUR SYSTEM YOU NEED TO HAVE THE DOCKER INSTALLED AND INSTALL HTTPD
docker run -it --name NAME_OF_CONATINER -p 4444:80 centos
After install httpd in the Docker container.
dnf install httpd -y
start the service
- By default systemclt command doesn’t present in the docker container, so we need to run the file of httpd.
- If you want to permanent httpd service.
- Go to /root/.bashrc file and type :