歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

Docker安裝應用(CentOS 6.5_x64)

Docker安裝應用(CentOS 6.5_x64)

Authoer::jom_ch@2014/7/23

Docker官網 http://www.docker.com/

一,安裝EPEL
 
關於EPEL:https://Fedoraproject.org/wiki/EPEL/zh-cn
 
>rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
 >rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
 >yum -y install yum -priorities
 

二,安裝Docker
 
>yum -y install docker-io
 >service docker start
 >chkconfig docker on
 

三,應用Docker
 
1,獲取Centos鏡像
 >docker pull centos:latest
 
2,查看鏡像運行情況
 >docker images centos
 
3,在容器下運行 shell bash
 >docker run -i -t centos /bin/bash
 
4,停止容器
 >docker stop <CONTAINER ID>
 
5,查看容器日志
 >docker logs -f <CONTAINER ID>
 
6,刪除所有容器
 >docker rm $(docker ps -a -q)
 
7,刪除鏡像
 >docker rmi <image id/name>
 
8,提交容器更改到鏡像倉庫中
 >docker run -i -t centos /bin/bash
 >useradd myuser
 >exit
 >docker ps -a |more
 >docker commit <CONTAINER ID> myuser/centos
 
9,創建並運行容器中的 hello.sh
 >docker run -i -t myuser/centos /bin/bash
 >touch /home/myuser/hello.sh
 >echo "echo \"Hello,World!\"" > /home/myuser/hello.sh
 >chmod +x /home/myuser/hello.sh
 >exit
 >docker commit <CONTAINER ID> myuser/centos
 >docker run -i -t myuser/centos /bin/sh /home/myuser/hello.sh
 
10,在容器中運行Nginx
 
在容器中安裝好Nginx,並提交到鏡像中
 >docker run -t -i -p 80:80 nginx/centos /bin/bash
 啟動Nginx
 >/data/apps/nginx/sbin/nginx
 (還不清楚如何在後台運行!!!)
 
在浏覽器訪問宿主機80端口。
 
11,映射容器端口
 >docker run -d -p 192.168.9.11:2201:22 nginx/centos /usr/sbin/sshd -D
 
用ssh [email protected] -p 2201 連接容器,提示:
 
Connection to 192.168.1.205 closed.(此問題還未解決!!!)
 

可能會遇到的問題:
 ##在容器裡面修改用戶密碼的時候報錯:
 /usr/share/cracklib/pw_dict.pwd: No such file or directory
 PWOpen: No such file or directory
 
解決:
 yum -y reinstall cracklib-dicts

開源項目Docker,Red Hat新的虛擬化選擇 http://www.linuxidc.com/Linux/2013-10/91051.htm

dockerlite: 輕量級 Linux 虛擬化 http://www.linuxidc.com/Linux/2013-07/87093.htm

Docker的搭建Gitlab CI 全過程詳解 http://www.linuxidc.com/Linux/2013-12/93537.htm

Docker 和一個正常的虛擬機有何區別? http://www.linuxidc.com/Linux/2013-12/93740.htm

在 Docker 中使用 MySQL http://www.linuxidc.com/Linux/2014-01/95354.htm

Docker 將改變所有事情 http://www.linuxidc.com/Linux/2013-12/93998.htm

Docker 1.0 正式版發布下載 http://www.linuxidc.com/Linux/2014-06/102941.htm

Docker 的詳細介紹:請點這裡
Docker 的下載地址:請點這裡

更多CentOS相關信息見CentOS 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=14

Copyright © Linux教程網 All Rights Reserved