Play Raspberry Pi Nginx Docker

本文介绍如何在 Raspberry Pi 上使用 Docker 部署 Nginx 服务。通过 Makefile 和 Dockerfile 的配置,实现 Nginx 的安装与运行,并提供默认配置文件访问 localhost 的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Play Raspberry Pi Nginx Docker

The project will be named as raspberrypi-nginx

normal Makefile as follow
IMAGE=sillycat/public
TAG=raspberrypi-nginx
NAME=raspberrypi-nginx

prepare:
wget http://nginx.org/download/nginx-1.11.6.tar.gz -P install/

docker-context:

build: docker-context
docker build -t $(IMAGE):$(TAG) .

run:
docker run -d -p 80:80 -v /opt/disk1/nas_cloud/sillycat/person:/data/sillycat -v /opt/disk1/nas_cloud/sillycat/share:/data/share --name $(NAME) $(IMAGE):$(TAG)

debug:
docker run -ti -p 80:80 -v /opt/disk1/nas_cloud/sillycat/person:/data/sillycat -v /opt/disk1/nas_cloud/sillycat/share:/data/share --name $(NAME) $(IMAGE):$(TAG) /bin/bash

clean:
docker stop ${NAME}
docker rm ${NAME}

logs:
docker logs ${NAME}

publish:
docker push ${IMAGE}:${TAG}

fetch:
docker pull ${IMAGE}:${TAG}


The Dockerfile will show how I install the nginx software on ubuntu initial image, I am using 1.11.6 version which is the latest currently.

#Set up nginx in Docker

#Prepre the OS
FROM resin/rpi-raspbian:jessie
MAINTAINER Carl Luo <luohuazju@gmail.com>

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update
RUN apt-get install -y apt-utils
RUN apt-get -y dist-upgrade
RUN apt-get install -y build-essential gcc make
RUN apt-get install -y libpcre3 libpcre3-dev zlib1g-dev libgcrypt11-dev

#install nginx
RUN mkdir -p /tool
RUN mkdir -p /install
ADD install/nginx-1.11.6.tar.gz /install/
WORKDIR /install/nginx-1.11.6
RUN ./configure --prefix=/tool/nginx-1.11.6
RUN make
RUN make install

#config nginx
ADD conf/nginx.conf /tool/nginx-1.11.6/conf/

#start the application
EXPOSE 80
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app/
CMD [ "./start.sh" ]

The script file start.sh to start the nginx service and keep it running in the back
#!/bin/sh -ex

#start the nginx
cd /tool/nginx-1.11.6
sbin/nginx -g "daemon off;"

Since I do not set up static html/js projects yet, so I just run this nginx project alone with default conf/nginx.conf

>make prepare
>make build
>make run

Visit the page http://localhost will work.

References:
http://sillycat.iteye.com/blog/2166582
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值