docker pull registry.cn-hangzhou.aliyuncs.com/centos-server/centos6:latest
docker images
#查看已有鏡像
#[root@localhost tmp]# docker images
#REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
#registry.cn-hangzhou.aliyuncs.com/centos-server/centos6 latest 1f7bf79ccbf3 8 months ago 260.9 MB
#改一下鏡像的REPOSITORY
docker tag 1f7bf79ccbf3 centos6
#刪除以前的鏡像,名字太長
docker rmi registry.cn-hangzhou.aliyuncs.com/centos-server/centos6
docker run -itd --name nginx centos6 /bin/bash
docker attach nginx
#下載依賴 wget https://ftp.pcre.org/pub/pcre/pcre-8.39.tar.gz wget www.zlib.net/fossils/zlib-1.2.8.tar.gz #下載安裝包 wget http://nginx.org/download/nginx-1.10.3.tar.gz #安裝依賴 yum install -y gcc* c++ openssl openssl-devel cyrus-sasl-md5 #解壓全部壓縮包 tar -zxvf pcre-8.39.tar.gz tar -zxvf zlib-1.2.8.tar.gz tar -zxvf nginx-1.10.3.tar.gz #安裝nginx cd nginx-1.10.3 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre=../pcre-8.39 --with-zlib=../zlib-1.2.8 make && make install #配置環境變量 vi /etc/profile export PATH="$PATH:/usr/local/nginx/sbin" source /etc/profile #修改nginx配置文件 vi /usr/local/nginx/conf/nginx.conf listen 8080 #啓動nginx nginx #測試 curl localhost:8080
exit #這種退出方式也會中止docker容器
docker commit -m 'Nginx' -a 'Centos-Nginx' 4188f4e5f136 registry.cn-hangzhou.aliyuncs.com/vlson/Centos-Nginx
docker save -o centos_nginx_docker_iso.tar registry.cn-hangzhou.aliyuncs.com/vlson/Centos-Nginx
docker push registry.cn-hangzhou.aliyuncs.com/vlson/Centos-Nginx
docker load --input centos_nginx_docker_iso.tar