docker apache安裝

文章來源:docker

1.添加鏡像apache

# docker pull httpd2.4

2.建立httpd文件spa

# mkdir /data/httpd2.4

3.啓動apacherest

# docker run -it -p 82:80 -d httpd

4.複製配置文件日誌

#### 複製根目錄
# docker cp httpd:/usr/local/apache2/htdocs /data/httpd2.4/www

#### 複製配置文件
# mkdir /data/httpd2.4/conf
# docker cp httpd:/usr/local/apache2/conf/httpd.conf /data/httpd2.4/conf/httpd.conf

#### 複製日誌文件
# docker cp httpd:/usr/local/apache2/logs /data/httpd2.4/logs

5.刪除httpd容器code

# docker rm -f httpd

6.配置httpd2.4而且啓動blog

# docker run -it -p 82:80 \
--name httpd2.4 --restart always \
-v /data/httpd2.4/www/:/usr/local/apache2/htdocs/ \
-v /data/httpd2.4/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf \
-v /data/httpd2.4/logs/:/usr/local/apache2/logs/ -d httpd

7.配置說明it

-p 80:80 :將容器的80端口映射到主機的80端口
-v /data/httpd2.4/www/:/usr/local/apache2/htdocs/ :將主機中當前目錄下的www目錄掛載到容器的/usr/local/apache2/htdocs/
-v /data/httpd2.4/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf :將主機中當前目錄下的conf/httpd.conf文件掛載到容器的/usr/local/apache2/conf/httpd.conf
-v /data/httpd2.4/logs/:/usr/local/apache2/logs/ :將主機中當前目錄下的logs目錄掛載到容器的/usr/local/apache2/logs/class

文章來源:容器

相關文章
相關標籤/搜索