Redis 和 Nginx Dockerfile

Redis

Dockerfile

	FROM ubuntu

	WORKDIR /root
	COPY redis-6.2.12.tar.gz /root
	RUN apt-get update -y \
			&& apt-get install -y  build-essential \
			&& tar zxvf redis-6.2.12.tar.gz \
			&& cd redis-6.2.12 \
			&& mkdir conf.d \
			&& make

	VOLUME ["/root/redis-6.2.12/conf.d"]
	EXPOSE 6379/tcp
	ENTRYPOINT /root/redis-6.2.12/src/redis-server /root/redis-6.2.12/conf.d/redis.conf

构建命令

	docker build -t adam-redis:6.2.12 .

启动命令

	docker run -d --name redis -p 6379:6379 -v /root/docker/redis:/root/redis-6.2.12/conf.d adam-redis:6.2.12

Nginx

Dockerfile

	FROM ubuntu

	WORKDIR /root
	RUN apt-get update -y \
			&& apt-get install -y nginx \
			&& sed -i 's/user www-data/user root/g' /etc/nginx/nginx.conf

	VOLUME ["/etc/nginx/conf.d", "/etc/nginx/conf"]
	EXPOSE 80/tcp
	ENTRYPOINT exec nginx -g 'daemon off;'		

构建命令

	docker build -t adam-nginx:20240305 .

运行命令

	docker run -d --name nginx  -p 9000:9000 -v /root/scripts/nginx.conf.d:/etc/nginx/conf.d -v /home/adam/deploy/frontend:/root/deploy/frontend adam-nginx:20240305

Q.E.D.