做Nginx镜像
mkdir nginx
cd nginx/
vim Dockerfile
docker build -t nginx:1.1 ./
docker run --name nginx -d -p 81:80 nginx:1.1
测试Nginx服务页面
做APACHE镜像
mkdir httpd
cd httpd/
vim Dockerfile
FROM centos
RUN yum -y install httpd
EXPOSE 80
CMD ["httpd","-DFOREGROUND"]
docker build -t httpd:1.1 ./
docker run --name httpd -d -p 80:80 httpd:1.1
测试httpd服务页面
做Tomcat镜像
mkdir tomcat
cd tomcat/
需要上传Tomcat源码包
tar zxf apache-tomcat-8.5.35.tar.gz
mv apache-tomcat-8.5.35 tomcat
rm -f apache-tomcat-8.5.35.tar.gz
vim Dockerfile
FROM java
COPY tomcat /usr/local/tomcat
EXPOSE 8080
WORKDIR /usr/local/tomcat
CMD ["./bin/catalina.sh","run"]
docker build -t tomcat:1.1 ./
docker run --name tomcat -d -p 82:8080 tomcat:1.1
测试Tomcat服务页面
做Redis镜像
首先我们可以从redis官网获取源码包
https://redis.io/download
或者使用wget命令获取Redis包
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
mkdir redis
cd redis/
vim Dockerfile
docker build -t redis:1.1 ./
docker run --name redis -d -p 6379:6379 redis:1.1
docker exec -it redis /bin/bash
redis-cli
set name hello
get name
vi /etc/redis.conf
exit
docker restart redis