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

Dockerfile installs the nginx container based on Centos7

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1. Create a Dockerfile file

Vim Dockerfile

# set a basic CentOS7 image, which is based on the following instructions: FROM centos:latest# author information MAINTAINER cjh# installation dependency tool & delete the default YUM source, and use the YUM source as the domestic 163YUM source RUN rpm-- rebuilddb;yum install make wget tar gzip passwd openssh-server gcc pcre-devel openssl-devel net-tools vim-yRUN rm-rf / etc/yum.repos.d/* Wget-P / etc/yum.repos.d/ http://mirrors.163.com/.help/CentOS7-Base-163.repo# configuration SSHD& modifies the root password to Mufeng07RUN ssh-keygen-Q-t rsa-b 2048-f / etc/ssh/ssh_host_rsa_key-N''RUN ssh-keygen-Q-t ecdsa-f / etc/ssh/ssh_host_ecdsa_key-N' 'RUN ssh-keygen-Q-t ed25519-f / etc/ssh/ssh_host_ ED25519_key-N''RUN echo' Mufeng07' | passwd-- download the latest version of Nginx software on the official website of Nginx RUN wget-P / tmp/ http://nginx.org/download/nginx-1.14.2.tar.gz# unpack the Nginx package and hide the WEB server version number RUN cd / tmp/;tar xzf nginx-1.14.2.tar.gz;cd nginx-1.14.2;sed-I-e's src/core/nginx.h# 1.14.2 s/nginx / WS/g'-e's / "NGINX" / "WS" / g 'src/core/nginx.h# creates configuration files based on source code installation RUN cd / tmp/nginx-1.14.2;./configure-- prefix=/usr/local/nginx-- with-http_stub_status_module-- with-http_ssl_module;make;make install# starts the Nginx service process and exposes ports 22 and 80; EXPOSE 22EXPOSE 80CMD / usr/local/nginx/sbin/nginx;/usr/sbin/sshd-D

2. Generate an image

Docker build-t centos7:nginx.

3. Create a container

# create a container based on centos7:nginx image

Docker run-itd-- privileged-p 80:80-p 2201 privileged 22-- name=mynginx centos7:nginx

# enter the container

Docker exec-it mynginx / bin/bash

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