In this lesson we will cover how to build your own custom Docker image from scratch. We'll walk through the process of starting a Debian container, installing packages and working through configuration issues, as well as a strategy for building a Dockerfile.
// Installl debian then swich to bash interactive mode docker run -it debian bash // download tegine curl http://tengine.taobao.org/download/tengine-2.2.0.tar.gz > /opt/tengine-2.2.0.tar.gz // If curl not found apt-get update apt-get install -y curl // cd to the download folder and unzip the file cd /opt tar xzf tengine-2.2.0.tar.gz // then you are able to see tegine-2.2.0 folder cd tengine-2.2.0 // Check the document how to install tegine apt-get install -y gcc apt-get install -y libpcre3 apt-get install -y libssl-dev ./configure pat-get install -y make make make install // After tegine was install, cd to the sbin folder and run nginx cd /usr/local/nginx/sbin /usr/local/nginx/sbin/nginx ps aux // check whether nginx started or not
Then we exit from the cmd:
exit mkdir tengine cd tengine/ vim Dockerfile
Building the docker file:
FROM debian RUN apt-get update && apt-get install -y curl gcc libpcre3-dev libssl-dev make RUN curl http://tengine.taobao.org/download/tengine-2.2.0.tar.gz > /opt/tengine-2.2.0.tar.gz WORKDIR /opt RUN tar xzf tengine-2.2.0.tar.gz WORKDIR /opt/tengine-2.2.0 RUN ./configure RUN make RUN make install // Then we need to start nginx: https://github.com/nginxinc/docker-nginx/blob/4d1f7f8ec281117d1d79bed4c6bc28b86039ca84/stable/stretch/Dockerfile // Can find cmd on Docker nginx hub RUN ln -sf /dev/stdout /usr/local/nginx/logs/access.log && ln -sf /dev/stderr /usr/local/nginx/logs/error.log EXPOSE 80 443 CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]
Now we can build our image:
docker build -t zwan/tengine:2.2.0 .
Check images:
dcoker images
Run image:
docker run -p 8000:80 zwan/tengine:2.2.0
Then check localhost:8000.