Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to start httpd in a docker container

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to start httpd in a docker container". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Httpd is the main program of the apache Hypertext transfer Protocol (http) server. Designed as a background process that runs independently, it establishes a pool of child processes or threads that process requests.

Install docker in ubuntu

~ # apt-get install docker.io

Ubuntu starts the docker service

~ # service docker start

Search for docker Ima

~ # docker search httpNAME DESCRIPTION STARS OFFICIAL AUTOMATEDhttpd The Apache HTTP Server Project 1830 [OK] haproxy HAProxy-The Reliable, High Performance T... 1001 [OK]. There are also many results that show that

Download the docker image of httpd

~ # docker pull httpd. Wait for the download to finish.

View native docker image

~ # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEhttpd latest 94af1f614752 4 days ago 178MB

The docker image running httpd becomes a container

~ # docker run-it-d-p 80:80-name datahttpd- v / data/:/usr/local/apache2/htdocs/ httpd~# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESf6bd2f6c6dfc httpd "httpd-foreground" 21 minutes ago Up 21 minutes 0.0.0.0 httpd-foreground 80-> 80/tcp datahttpd-i interaction-t console-d background operation-p native port: Port mapped to this docker image-name is the name of the docker container-v native path: path mapped to this docker image

Verify the httpd service

Use curl to view native httpd services

~ # curl localhostIndex of / Index of / Anaconda3-5.2.0-Linux-x86_64.sh Anaconda3-5.2.0-MacOSX-x86_64.pkg Anaconda3-5.2.0-Windows-x86_64.exe

Use netstat to view the running port and confirm that docker uses port 80

~ # netstat-aptnActive Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 00 0.0.0.0 LISTEN 937/sshdtcp 00 172.17.42.41 * LISTEN 937/sshdtcp 00 175.171.173.103 ESTABLISHED 1100/1tcp 00 172.17.42.41 netstat 51614 106.11.68.13 80 ESTABLISHED 843/AliYunDuntcp 00 172.17.42.41L LISTEN 937/sshdtcp 22 175.171.173.103 ESTABLISHED 977/0tcp 0232 172.17.42.41 ESTABLISHED 1141/2tcp6 22 175.171.173.103 ESTABLISHED 1141/2tcp6 00:: 80: * LISTEN 26005/docker-proxy "how to launch httpd in a httpd container" ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report