How do docker containers run web applications?
How do docker containers run web applications? I believe that many novice rookies have not yet learned this skill, through the summary of this article, I hope you can learn to use docker containers to run web applications. The following information is about how the docker container runs the web application.
1. Run a Python Flask application in a dcoekr container to run a web application
[root@localhost ~] # docker pull training/webapp # load image
[root@localhost] # docker run-d-P training/webapp python app.py
Parameter description:
-d: let the container run in the background
-p: map the network ports used inside the container to the host
2. View the web application container
1) View the running container
[root@localhost ~] # docker ps
More port information
2) access the web application through the browser
3) set different ports through the-p parameter
[root@localhost] # docker run-d-p 5000 training/webapp python app.py
4) Shortcut of network port
You can use the docker ps command to produce the mapped port of the running container. Docke also provides another shortcut, docker port. You can use docker port to check the port number of a specified (ID or name) container mapped to the host.
[root@localhost ~] # docker port 288dc71d0ce0
3. View the web application log
Docker logs [ID or name] can view the standard output inside the container
[root@localhost ~] # docker logs 288dc71d0ce0
4. View the progress of the web application container
[root@localhost ~] # docker top 288dc71d0ce0
5. Check the web application
[root@localhost ~] # docker inspect 288dc71d0ce0
6. Stop the web application
[root@localhost ~] # docker stop 288dc71d0ce0
7. Start the web application container
[root@localhost ~] # docker start 288dc71d0ce0
8. Remove web applications
[root@localhost ~] # docker rm 288dc71d0ce0
When deleting a container, the container must be stopped, otherwise an error will be reported
The above is the introduction of the method of running web application with docker container, and you have to use it before you know the details. If you want to read more related articles, you are welcome to follow the industry information channel!