Docker安裝應用程式(Centos6.5_x64)

來源:互聯網
上載者:User

標籤:

Docker安裝應用程式(Centos6.5_x64)


Authoer::[email protected]/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,在nginx.conf頭部加入:
daemon off;
儲存,退出容器提交到鏡像中。
啟動Docker中的Nginx
>docker run -d -p 81:80 nginx/centos /data/apps/nginx/sbin/nginx
在瀏覽器訪問宿主機81port。

11。映射容器port
>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.(此問題還未解決!!!)


可能會遇到的問題:
##在容器裡面改動使用者password的時候報錯:
/usr/share/cracklib/pw_dict.pwd: No such file or directory
PWOpen: No such file or directory

解決:
yum -y reinstall cracklib-dicts

著作權聲明:本文部落格原創文章,部落格,未經同意,不得轉載。

Docker安裝應用程式(Centos6.5_x64)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.