What is Docker?
Docker for python– Docker has become one of the demanded technologies in this fast-growing tech era. In simple words, docker can be said as a container. For example, consider a ship that needs to be loaded with goods. It will take a lot of time to load one by one and adjusting it based on the space. Instead, one can take a container load everything in the container and just place the container on the ship. This will reduce your time, space, and labor too. The same reasons are behind the usage of docker. By using a docker, one can solve dependency conflicts i.e. version conflicts of software won’t occur, can easily scale up i.e. it handles the issue of single server facing higher usage problem, etc.
Writing a docker file:
The standard 5 commands used in dockerfile are:
FROM python: 3.6
COPY src/requirements.txt ./
RUN pip install -r requirements.txt
COPY src /app
FROM “base image” – this specifies which python image has to be used as the base image
WORKDIR “working directory” – specifies the location of the working directory
COPY “source” “destination” – copies the contents from the source file to the destination file
RUN “pip install requirements” – runs the installation of all the requirements for the application
COPY “source” “destination” – copies all the installation from the source to the destination which is the working directory
CMD[“technology”,”entrypoint”] – specifies which technology is used i.e. in this case it is python and the entrypoint specifies the python file which acts as the entrypoint to run the application
If you are writing a python dockerfile for a web application you can also use “EXPOSE” command in the dockerfile.
EXPOSE “portnumber” – specifies the portnumber in which the localhost must run in the browser
Building a docker image:
docker build -t docker-image
docker run –rm docker-image
The above commands are used to build the image and run the dockerfile for your application.
Hers, -t is specified in front of the desired image. An image can be created without specifying a name. The image is always created with an auto-generated unique ID, thus making it an optional parameter.
And, –rm is specified near the run command. This ensures that the container that has been created is automatically deleted once it has stopped.
This post is contributed by Kushmitha Radhakrishnan.
The system of the binary conversion
The binary number system defines a number in a binary system. You only find the number in a two-number system the 1 and the 0. The binary number system is an alternative system of representation to the decimal number system. The decimal number system is from (0 to 9) and has a base of 10…
What is web development for beginners?
Introduction In web development, we refer to website so web development refers to website development. “Web” word has been taken from the spider’s web because of the analogy that like a web is connected similarly websites are also connected to each other through the Internet. History of web development 1989: Proposal for the World Wide…
Guide to Proxy Servers: How They Work and Why You Need Them?
What is a web proxy? During our college days, we often heard the term “proxy” which referred to the act of someone else marking our attendance, allowing us to be present in a class even if we were not physically there. In the context of the Internet, a web proxy works similarly, acting as an…
Continue Reading Guide to Proxy Servers: How They Work and Why You Need Them?
Python | Check Armstrong Number using for loop
An Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits. Consider 153. It has 3 digits, so we raise each digit to the power of 3(the number of digits) and sum them up:1^3 + 5^3 + 3^3 = 1 +…
Continue Reading Python | Check Armstrong Number using for loop
Python | Factorial of a number using for loop
The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. The factorial of 0 is defined to be 1. The factorial formula can be expressed as: n! = 1 * 2 * 3 * … * n Code to calculate factorial of…
Continue Reading Python | Factorial of a number using for loop
Link in bio
Python Mega Course 2023 Radha Krishna Python Code