一、安装dokcer:
从官网下载docker镜像并安装;
二、查找centos镜像:
macbook:portal zhaoxueyong$ docker search centos
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 3579 [OK]
ansible/centos7-ansible Ansible on Centos7 100 [OK]
jdeathe/centos-ssh CentOS-6 6.9 x86_64 / CentOS-7 7.3.1611 x8... 81 [OK]
tutum/centos Simple CentOS docker image with SSH access 33
imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 30 [OK]
gluster/gluster-centos Official GlusterFS Image [ CentOS-7 + Glu... 19 [OK]
kinogmt/centos-ssh CentOS with SSH 16 [OK]
centos/php-56-centos7 PHP 5.6 platform for building and running ... 8
guyton/centos6 From official centos6 container with full ... 7 [OK]
openshift/base-centos7 A Centos7 derived base image for Source-To... 7
openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 ima... 6
openshift/ruby-20-centos7 DEPRECATED: A Centos7 based Ruby v2.0 imag... 3
darksheer/centos Base Centos Image -- Updated hourly 3 [OK]
...
三、下载centos镜像:
macbook:portal zhaoxueyong$ docker pull centos
Using default tag: latest
latest: Pulling from library/centos
74f0853ba93b: Pull complete
Digest: sha256:26f74cefad82967f97f3eeeef88c1b6262f9b42bc96f2ad61d6f3fdf544759b8
Status: Downloaded newer image for centos:latest
四、启动容器:
macbook:portal zhaoxueyong$ docker run -t -i --name=python-env centos
[root@00183564ac22 /]#
五、容器中部署环境:
...
六、退出容器:
Dependency Installed:
gpm-libs.x86_64 0:1.20.7-5.el7 groff-base.x86_64 0:1.22.2-8.el7 perl.x86_64 4:5.16.3-291.el7 perl-Carp.noarch 0:1.26-244.el7
perl-Encode.x86_64 0:2.51-7.el7 perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7
perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-2.el7 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-PathTools.x86_64 0:3.40-5.el7
perl-Pod-Escapes.noarch 1:1.04-291.el7 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7
perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-4.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7
perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-291.el7
perl-macros.x86_64 4:5.16.3-291.el7 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7
perl-threads-shared.x86_64 0:1.43-6.el7 vim-common.x86_64 2:7.4.160-1.el7_3.1 vim-filesystem.x86_64 2:7.4.160-1.el7_3.1 which.x86_64 0:2.20-7.el7
Complete!
[root@00183564ac22 /]# ls
anaconda-post.log bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
[root@00183564ac22 /]# exit
exit
七、重新进入容器:
macbook:portal zhaoxueyong$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
00183564ac22 centos "/bin/bash" 15 minutes ago Exited (0) About a minute ago python-env
cea3afc41538 hello-world "/hello" 37 hours ago Exited (0) 37 hours ago competent_shockley
macbook:portal zhaoxueyong$ docker start 00183564ac22
00183564ac22
macbook:portal zhaoxueyong$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
00183564ac22 centos "/bin/bash" 19 minutes ago Up 3 seconds python-env
cea3afc41538 hello-world "/hello" 38 hours ago Exited (0) 38 hours ago competent_shockley
macbook:portal zhaoxueyong$ docker attach 00183564ac22
[root@00183564ac22 /]#