• %user%
logotype
SysOps
  • Главная
  • Новости
  • О проекте
  • Контакты

  • RHEL
  • Ubuntu
  • TCP/IP
  • DNS
  • Containers
  • Cloud
  • Nginx
  • LAMP Stack
  • LEMP Stack
  • SQL
  • Zabbix
  • Netfilter

Разворачиваем NGINX в Docker


Устанавливаем движок Docker'a в CentOS:
yum-config-manager     --add-repo     https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io -y

Запускаем движок Docker'a:
systemctl start docker

Проверяем статус:
systemctl status docker

Содержимое Dockerfile:
vi Dockerfile-Ubuntu-Nginx
############################################################
# Dockerfile to build Nginx Installed Containers
# Based on Ubuntu with LTS
############################################################

# Set the base image to Ubuntu 
FROM ubuntu:20.04

# File Author / Maintainer
MAINTAINER Sobir Akbarov <[email protected]>

# Update the repository
RUN apt-get update

# Install necessary tools
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install apt-utils dialog iproute2 dnsutils inetutils-ping ncat nano less wget -y

# Download and install NGINX
RUN apt-get install nginx -y  

# Remove the default NGINX configuration file
RUN rm -v /etc/nginx/nginx.conf

# Copy a configuration file from the current directory
ADD nginx.conf /etc/nginx/

# Append "daemon off;" to the ending of the configuration
RUN echo "daemon off;" >> /etc/nginx/nginx.conf

# Expose ports
EXPOSE 80
EXPOSE 443

# Set the default command to execute
# when creating a new container
CMD service nginx start

Содержимое nginx.conf:
vi nginx.conf
user  www-data;
pid   /run/nginx.pid;
worker_processes  auto;
worker_rlimit_nofile 65535;
error_log  /var/log/nginx/error.log warn;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 65535;
    use epoll;
    multi_accept on;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    server_names_hash_bucket_size 64;
    server_tokens off;
    gzip  on;

    server {
        listen       0.0.0.0:80 default_server;
        server_name  localhost;
        root	     /var/www/html;

        location / {
            deny all;
        }

        error_page 404 /404.html;
    	    location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
    	    location = /50x.html {
        }
    }    

    include /etc/nginx/conf.d/*.conf;
}

Выполняем сборку образа командой:
docker build -f Dockerfile-Ubuntu-Nginx -t nginx:custom .

Просмотр доступных образов:
docker images

Запускаем образ nginx:
docker run --rm -d --name web -v /data/app:/var/www/html -p 0.0.0.0:80:80 nginx:custom

Проверяем запущенный процесс контейнера:
docker ps

  • Комментарии
  • О статье
  • Похожие новости
У данной публикации нет комментариев.

sobir

Автор

22-06-2021, 16:56

Дата пуликации

Containers

Категория
  • Комментариев: 0
  • Просмотров: 357
RHEL / Containers
Запуск systemd в контейнере в CentOS 8 / RHEL 8
RHEL / Containers
Настройка среды контейнеризации приложений на Docker / Podman в CentOS 8 / RHEL
Containers
Отслеживаем соединения контейнеров Docker
RHEL / Nginx
Установка веб сервера NGINX в CentOS 8 / RHEL 8
RHEL / Nginx / LAMP Stack / LEMP Stack
Настройка полноценного веб сервера NGINX + Apache + FPM в CentOS 8 / RHEL 8
Написать комментарий
Имя:*
E-Mail:

  • Смайлы и люди
    Животные и природа
    Еда и напитки
    Активность
    Путешествия и места
    Предметы
    Символы
    Флаги

Комментарии
Hi tһere, I would like what hɑs һappened
to abc classic fm
? subscribe fоr this web site
tо tаke most սp-to-ⅾate updates, tһerefore ѡherе сan i do it please help out.
14 мая 2022 11:52

Lenora

<a href=https://sites.google.com/view/hondrostrong-crema-italia/>hondrostrong crema italia</a>
21 апреля 2022 22:48

RQEric

Принудительное обновление сертификата:

certbot certonly --force-renew -d newsite.com
17 октября 2021 11:40

sobir

Получаем SSL сертификат с помощью плагина nginx:

certbot certonly --nginx -d newsite.com -d www.newsite.com
7 августа 2021 15:35

sobir

Можно, но я решил описать процесс копирования ключей более подробно.
3 июля 2021 14:19

sobir

Какой дистрибутив Linux вы часто используете?
Реклама
1 посетитель на сайте. Из них:
Гости1
© 2020 SysOps Яндекс.Метрика

Авторизация

Регистрация Забыли пароль?