###centos7 部署docker### 一、獲取阿里docker yum源 wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce-staging.repohtml
yum makecachemysql
yum repolistlinux
二、移除舊版dockernginx
yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
三、安裝依賴包 yum install -y yum-utils
device-mapper-persistent-data
lvm2redis
四、安裝最新版dockersql
yum -y install docker-ce:latest systemctl start docker systemctl enable docker
五、運行hello-world鏡像mongodb
docker run hello-world docker
六、配置阿里雲加速 json
mkdir -p /etc/docker tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://bmmh6qxh.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
七、若是docker命令沒法自動補全安裝bash-completion從新打開終端便可centos
yum install -y bash-completion
###2、docker環境部署nginx### 一、進入docker hub,查看並下載相關鏡像的版本,網址www.hub.docker.com;
docker pull nginx:latest
二、建立nginx配置文件目錄並運行容器 mkdir -p /usr/local/nginx/conf/conf.d
docker run --name nginx -d nginx:latest
拷貝容器內nginx配置日誌文件到宿主機
docker cp nginx:/etc/nginx/conf.d/default.conf /usr/local/nginx/conf/conf.d docker cp nginx:/usr/share/nginx/html /usr/local/nginx/ docker cp nginx:/var/log/nginx /usr/local/nginx/logs/ docker stop nginx docker rm nginx
三、運行容器暴露端口,並將容器目錄掛載至宿主機
docker run --name nginx -d -p 8002:80 \ -v /usr/local/nginx/html:/usr/share/nginx/html \ -v /usr/local/nginx/conf/conf.d:/etc/nginx/conf.d \ -v /usr/local/nginx/logs/nginx:/var/log/nginx/ nginx
四、使用瀏覽器打開nginx
###3、docker環境部署tomcat### 一、拉取鏡像
docker pull tomcat:latest
二、運行tomcat容器, docker run --name tomcat -d -p 8003:8080 tomcat:latest
三、使用瀏覽器打開
###4、docker環境部署redis###
一、拉取鏡像
docker pull redis:5.0.7
二、運行redis容器 docker run --name redis -d -p 36379:6379 redis:5.0.7
三、使用redis 鏈接工具測試
下一篇docekr環境部署mysql、kakka、mongodb和搭建私有redistry;