Docker(Ⅹ)-基于官方Ubuntu基础镜像制作自定义镜像

基于官方Ubuntu基础镜像制作自定义镜像

//确认工作目录
pwd
/opt/docker/system/ubuntu

//编写Dockerfile文件
vim Dockersfile

#Ubuntu Base Image
#
FROM ubuntu:18.04

RUN  apt update && apt install -y iproute2 ntpdate tcpdump telnet traceroute nfs-kernel-server nfs-common lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute gcc openssh-server lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute iotop unzip zip make && touch /tmp/linux.txt

ADD nginx-1.16.1.tar.gz /usr/local/src

RUN cd /usr/local/src/nginx-1.16.1 && ./configure --prefix=/apps/nginx && make && make install && ln -sv /apps/nginx/sbin/nginx /usr/bin  

RUN cd /usr/local/src && rm -rf nginx-1.16.1.tar.gz 

ADD nginx.conf /apps/nginx/conf/nginx.conf

ADD index.html /data/nginx/html/index.html

RUN groupadd -g 2019 nginx && useradd -g nginx -s /usr/sbin/nologin -u 2019 nginx && chown -R nginx.nginx /apps/nginx /data/nginx

EXPOSE 80 443

CMD ["nginx","-g","daemon off;"]
//确认工作目录
pwd
/opt/docker/system/ubuntu

//编写sources.list文件
vim sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
//确认工作目录
pwd
/opt/docker/system/ubuntu

//编写Dockerfile文件
vim build-command.sh 

#!/bin/bash
docker build -t ubuntu-nginx:v0.1 ./
点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注