首先安裝環境的準備,docker好像不支持32位的系統。(本人實驗得出的結果7.0系統的安裝包不一樣於6.X的) php
我安裝的是CentOS6.6的虛擬機 java
首先配置擴展源epel node
#cd /etc/yum.repos.d/ mysql
#wget http://mirrors.aliyun.com/repo/epel-6.repo linux
#yum clean all golang
#yum makecache sql
#yum search docker-io docker
Loaded plugins: fastestmirror shell
Loading mirror speeds from cached hostfile apache
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.7 kB 00:00
epel | 4.4 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
============================ N/S Matched: docker-io ============================
docker-io.x86_64 : Automates deployment of containerized applications
docker-io-devel.x86_64 : A golang registry for global request variables (source
: libraries)
docker-io-fish-completion.x86_64 : fish completion files for docker
docker-io-logrotate.x86_64 : cron job to run logrotate on docker containers
docker-io-pkg-devel.x86_64 : A golang registry for global request variables
: (source libraries)
docker-io-vim.x86_64 : vim syntax highlighting files for docker
docker-io-zsh-completion.x86_64 : zsh completion files for docker
Name and summary matches only, use "search all" for everything.
#yum install -y docker-io
Starting cgconfig service: [ OK ]
Starting docker: [ OK ]
#service iptables stop
iptables: Setting chains to policy ACCEPT: filter nat [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
# docker search centos
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 886 [OK]
ansible/centos7-ansible Ansible on Centos7 35 [OK]
tutum/centos Centos p_w_picpath with SSH access. For the root... 13 [OK]
jdeathe/centos-ssh-apache-php CentOS-6 6.5 x86_64 / Apache / PHP / PHP m... 9 [OK]
blalor/centos Bare-bones base CentOS 6.5 p_w_picpath 9 [OK]
jprjr/centos-php-fpm 6 [OK]
steeef/graphite-centos CentOS 6.x with Graphite and Carbon via ng... 6 [OK]
tutum/centos-6.4 DEPRECATED. Use tutum/centos:6.4 instead. ... 5 [OK]
million12/centos-supervisor Base CentOS-7 with supervisord launcher, h... 2 [OK]
layerworx/centos A general CentOS 6 p_w_picpath with the EPEL6 an... 2 [OK]
nimmis/java-centos This is docker p_w_picpaths of CentOS 7 with dif... 1 [OK]
jdeathe/centos-ssh CentOS-6 6.5 x86_64 / EPEL Repo. / OpenSSH... 1 [OK]
jdeathe/centos-ssh-mysql CentOS-6 6.5 x86_64 / MySQL. Image include... 1 [OK]
internavenue/centos-percona Centos-based Percona p_w_picpath. 1 [OK]
tcnksm/centos-node Dockerfile for CentOS packaging node 1 [OK]
yajo/centos-epel CentOS with EPEL and fully updated 1 [OK]
jr42/chef-solo-centos Official CentOS base p_w_picpaths with current c... 1 [OK]
feduxorg/centos-rails 0 [OK]
akroh/centos Centos 6 container that has been updated w... 0 [OK]
snowyday/centos Provide for emacs and Ricty font on X11 en... 0 [OK]
dmglab/centos CentOS with superpowers! 0 [OK]
m0ikz/centos 0 [OK]
lighthopper/openjdk-centos A Dockerfile for creating an OpenJDK p_w_picpath... 0 [OK]
solict/provisionous-puppet-centos CentOS provisions with Puppet included 0 [OK]
insaneworks/centos CentOS 6.5 x86_64 + @update 0 [OK]
#docker pull jdeathe/centos-ssh-mysql //下載docker鏡像名爲jdeathe/centos-ssh-mysql
Pulling repository jdeathe/centos-ssh-mysql
8f3141d0a29c: Pulling dependent layers
511136ea3c5a: Download complete
5b12ef8fd570: Download complete
a30bc9f3097e: Download complete
4fba16602a0b: Download complete
a891edd39204: Download complete
3eba1982eb12: Download complete
54352c2c5f97: Download complete
8f3141d0a29c: Download complete
faf07413a5d4: Download complete
e9a8f0d9df6a: Download complete
5f00cdf32e1e: Download complete
5c8e91c6a79a: Download complete
ddf8ddc713b3: Download complete
ec03dde110a6: Download complete
e10e84e0794c: Download complete
5cb7e5ea7912: Download complete
29eaef6634f3: Download complete
b61f99256061: Download complete
9ed9684bf6b2: Download complete
ca0d772af8ba: Download complete
364e3c41c3ea: Download complete
08c78beb9784: Download complete
ca199e68d966: Download complete
a22541c2ef10: Download complete
3e9e5d2a415a: Download complete
50644b3f30c3: Download complete
244ad13c7882: Download complete
3743a2b6a6bd: Download complete
f7c8540540c0: Download complete
Status: Downloaded newer p_w_picpath for jdeathe/centos-ssh-mysql:latest
#docker run -i -t jdeathe/centos-ssh-mysql bash //交互式登陸docker
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory
[root@42cf5f62dfa2 /]# ls
bin etc lib lost+found mnt proc sbin srv tmp var
dev home lib64 media opt root selinux sys usr
# docker run -i -t jdeathe/centos-ssh-mysql /bin/sh //交互式登陸docker 當前shell爲 /bin/sh
sh-4.1# ls
bin etc lib lost+found mnt proc sbin srv tmp var
dev home lib64 media opt root selinux sys usr
sh-4.1#
sh-4.1#exit
#docker ps -a |grep mysql
8a6344f013a9 jdeathe/centos-ssh-mysql:latest "/bin/sh" 33 minutes ago Exited (2) 11 minutes ago cocky_morse
d4a564d0769a jdeathe/centos-ssh-mysql:latest "/bin/bash" 34 minutes ago Exited (0) 34 minutes ago desperate_bohr
42cf5f62dfa2 jdeathe/centos-ssh-mysql:latest "bash" 44 minutes ago Exited (0) 41 minutes ago evil_morse
#docker commit -m "jdeathe/centos-ssh-mysql+httpd" evil_morse apache //建立本身的鏡像 apache,在原來的鏡像上安裝了http的服務
7ab0efe81674f51e0482d0b2b834926430fd974b162ef5ebbbd2f7d0b8f8baef
#docker p_w_picpaths //查看本身建立的鏡像
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
apache latest 7ab0efe81674 14 seconds ago 331.1 MB
jdeathe/centos-ssh-mysql latest 8f3141d0a29c 3 weeks ago 331.1 MB
jdeathe/centos-ssh latest 171447906a92 3 weeks ago 251.7 MB
搭建本身的docker倉庫
#yum install -y docker-registry
啓動docker倉庫:
#service docker-registry start // 7.0系統 #systemctl start docker-registry
配置防火牆;
# firewall-cmd --permanent --add-port=5000/tcp
# firewall-cmd --reload
#docker tag apache-1 server0.example.com:5000/httpd //上傳鏡像到倉庫
#docker push server0.example.com:5000/httpd
#docker pull server0.example.com:5000/httpd //從倉庫拉取鏡像:
#docker save --output=rhel-apache.tar apache //輸出鏡像到文件
#tar -tf rhel-apache.tar
08c78beb97847716cc87c8a2f4eb777d08e8fd9c559f1df14f6ab058fe983295/
08c78beb97847716cc87c8a2f4eb777d08e8fd9c559f1df14f6ab058fe983295/VERSION
08c78beb97847716cc87c8a2f4eb777d08e8fd9c559f1df14f6ab058fe983295/json
08c78beb97847716cc87c8a2f4eb777d08e8fd9c559f1df14f6ab058fe983295/layer.tar
244ad13c78827aedc88eaa603b9a27411c5b28e0e6d5bd6c1676e9f527d6f603/
244ad13c78827aedc88eaa603b9a27411c5b28e0e6d5bd6c1676e9f527d6f603/VERSION
244ad13c78827aedc88eaa603b9a27411c5b28e0e6d5bd6c1676e9f527d6f603/json
244ad13c78827aedc88eaa603b9a27411c5b28e0e6d5bd6c1676e9f527d6f603/layer.tar
29eaef6634f3198a784bcde7e1dadaed254fae7acea5b16f7d9cd049ded4d5ac/
29eaef6634f3198a784bcde7e1dadaed254fae7acea5b16f7d9cd049ded4d5ac/VERSION
29eaef6634f3198a784bcde7e1dadaed254fae7acea5b16f7d9cd049ded4d5ac/json
29eaef6634f3198a784bcde7e1dadaed254fae7acea5b16f7d9cd049ded4d5ac/layer.tar
364e3c41c3ea3975926d3eaebbe453b36b772c9a7892941387eb77d49ae5067c/
364e3c41c3ea3975926d3eaebbe453b36b772c9a7892941387eb77d49ae5067c/VERSION
364e3c41c3ea3975926d3eaebbe453b36b772c9a7892941387eb77d49ae5067c/json
364e3c41c3ea3975926d3eaebbe453b36b772c9a7892941387eb77d49ae5067c/layer.tar
3743a2b6a6bd3cefd8e9964f1e1310420f0f554c21b120056867b4cb11c39142/
3743a2b6a6bd3cefd8e9964f1e1310420f0f554c21b120056867b4cb11c39142/VERSION
3743a2b6a6bd3cefd8e9964f1e1310420f0f554c21b120056867b4cb11c39142/json
3743a2b6a6bd3cefd8e9964f1e1310420f0f554c21b120056867b4cb11c39142/layer.tar
3e9e5d2a415ac6a92c8994782f3ba2a22d60b12e17d088b21dc3dc0c88f72e0c/
3e9e5d2a415ac6a92c8994782f3ba2a22d60b12e17d088b21dc3dc0c88f72e0c/VERSION
3e9e5d2a415ac6a92c8994782f3ba2a22d60b12e17d088b21dc3dc0c88f72e0c/json
3e9e5d2a415ac6a92c8994782f3ba2a22d60b12e17d088b21dc3dc0c88f72e0c/layer.tar
3eba1982eb1273d9572d629b04f98b50d2ad98d3243817dd60cc36eabee8ace9/
3eba1982eb1273d9572d629b04f98b50d2ad98d3243817dd60cc36eabee8ace9/VERSION
3eba1982eb1273d9572d629b04f98b50d2ad98d3243817dd60cc36eabee8ace9/json
3eba1982eb1273d9572d629b04f98b50d2ad98d3243817dd60cc36eabee8ace9/layer.tar
4fba16602a0bea9fa7a140600b8b75f176a4a749c08d94af0f13701310230956/
4fba16602a0bea9fa7a140600b8b75f176a4a749c08d94af0f13701310230956/VERSION
4fba16602a0bea9fa7a140600b8b75f176a4a749c08d94af0f13701310230956/json
4fba16602a0bea9fa7a140600b8b75f176a4a749c08d94af0f13701310230956/layer.tar
50644b3f30c3c92b9e9b63c6fbfb46daa898eb616a7d366673673d1260267404/
50644b3f30c3c92b9e9b63c6fbfb46daa898eb616a7d366673673d1260267404/VERSION
50644b3f30c3c92b9e9b63c6fbfb46daa898eb616a7d366673673d1260267404/json
50644b3f30c3c92b9e9b63c6fbfb46daa898eb616a7d366673673d1260267404/layer.tar
511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/
511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/VERSION
511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json
511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer.tar
54352c2c5f97e983ea82d8eb0df45765029b69e996169077c72babcc8a198cb3/
54352c2c5f97e983ea82d8eb0df45765029b69e996169077c72babcc8a198cb3/VERSION
54352c2c5f97e983ea82d8eb0df45765029b69e996169077c72babcc8a198cb3/json
54352c2c5f97e983ea82d8eb0df45765029b69e996169077c72babcc8a198cb3/layer.tar
5b12ef8fd57065237a6833039acc0e7f68e363c15d8abb5cacce7143a1f7de8a/
5b12ef8fd57065237a6833039acc0e7f68e363c15d8abb5cacce7143a1f7de8a/VERSION
5b12ef8fd57065237a6833039acc0e7f68e363c15d8abb5cacce7143a1f7de8a/json
5b12ef8fd57065237a6833039acc0e7f68e363c15d8abb5cacce7143a1f7de8a/layer.tar
5c8e91c6a79a718e03e661578a363fc76a797cb040312cd653cd77fd59305fe1/
5c8e91c6a79a718e03e661578a363fc76a797cb040312cd653cd77fd59305fe1/VERSION
5c8e91c6a79a718e03e661578a363fc76a797cb040312cd653cd77fd59305fe1/json
5c8e91c6a79a718e03e661578a363fc76a797cb040312cd653cd77fd59305fe1/layer.tar
5cb7e5ea79126202269bf68abd7bbe8898dbd70d19929882fbe77ada7ff9923b/
5cb7e5ea79126202269bf68abd7bbe8898dbd70d19929882fbe77ada7ff9923b/VERSION
5cb7e5ea79126202269bf68abd7bbe8898dbd70d19929882fbe77ada7ff9923b/json
5cb7e5ea79126202269bf68abd7bbe8898dbd70d19929882fbe77ada7ff9923b/layer.tar
5f00cdf32e1e36cc49a8e4152cb39d6804b5ba554279b9266b46519fa26bf080/
5f00cdf32e1e36cc49a8e4152cb39d6804b5ba554279b9266b46519fa26bf080/VERSION
5f00cdf32e1e36cc49a8e4152cb39d6804b5ba554279b9266b46519fa26bf080/json
5f00cdf32e1e36cc49a8e4152cb39d6804b5ba554279b9266b46519fa26bf080/layer.tar
7ab0efe81674f51e0482d0b2b834926430fd974b162ef5ebbbd2f7d0b8f8baef/
7ab0efe81674f51e0482d0b2b834926430fd974b162ef5ebbbd2f7d0b8f8baef/VERSION
7ab0efe81674f51e0482d0b2b834926430fd974b162ef5ebbbd2f7d0b8f8baef/json
7ab0efe81674f51e0482d0b2b834926430fd974b162ef5ebbbd2f7d0b8f8baef/layer.tar
8f3141d0a29c5431a6bad2224e03f97a04b00fe14c0e46b9b0d2faff0c3e81ec/
8f3141d0a29c5431a6bad2224e03f97a04b00fe14c0e46b9b0d2faff0c3e81ec/VERSION
8f3141d0a29c5431a6bad2224e03f97a04b00fe14c0e46b9b0d2faff0c3e81ec/json
8f3141d0a29c5431a6bad2224e03f97a04b00fe14c0e46b9b0d2faff0c3e81ec/layer.tar
9ed9684bf6b2c6389f6124939082b794f04202e1157063dc2524ae91c963c92d/
9ed9684bf6b2c6389f6124939082b794f04202e1157063dc2524ae91c963c92d/VERSION
9ed9684bf6b2c6389f6124939082b794f04202e1157063dc2524ae91c963c92d/json
9ed9684bf6b2c6389f6124939082b794f04202e1157063dc2524ae91c963c92d/layer.tar
a22541c2ef10eca3d2d67e4b28092bd9472c88234f0ecd38d7629653559b14ba/
a22541c2ef10eca3d2d67e4b28092bd9472c88234f0ecd38d7629653559b14ba/VERSION
a22541c2ef10eca3d2d67e4b28092bd9472c88234f0ecd38d7629653559b14ba/json
a22541c2ef10eca3d2d67e4b28092bd9472c88234f0ecd38d7629653559b14ba/layer.tar
a30bc9f3097ea36bfd37fecf575c2c63f5ba99b618916422c13ee3f12ecbf2e8/
a30bc9f3097ea36bfd37fecf575c2c63f5ba99b618916422c13ee3f12ecbf2e8/VERSION
a30bc9f3097ea36bfd37fecf575c2c63f5ba99b618916422c13ee3f12ecbf2e8/json
a30bc9f3097ea36bfd37fecf575c2c63f5ba99b618916422c13ee3f12ecbf2e8/layer.tar
a891edd39204eeceb9e25556bada50903e0af37c057d5ded9790d9234b8534f5/
a891edd39204eeceb9e25556bada50903e0af37c057d5ded9790d9234b8534f5/VERSION
a891edd39204eeceb9e25556bada50903e0af37c057d5ded9790d9234b8534f5/json
a891edd39204eeceb9e25556bada50903e0af37c057d5ded9790d9234b8534f5/layer.tar
b61f992560613751ac397911c65611650f4ffc08a819a55f194ff97468d312f6/
b61f992560613751ac397911c65611650f4ffc08a819a55f194ff97468d312f6/VERSION
b61f992560613751ac397911c65611650f4ffc08a819a55f194ff97468d312f6/json
b61f992560613751ac397911c65611650f4ffc08a819a55f194ff97468d312f6/layer.tar
ca0d772af8ba1afb6f90e51fee60178fc92823642a8d83d837f14727768e25ef/
ca0d772af8ba1afb6f90e51fee60178fc92823642a8d83d837f14727768e25ef/VERSION
ca0d772af8ba1afb6f90e51fee60178fc92823642a8d83d837f14727768e25ef/json
ca0d772af8ba1afb6f90e51fee60178fc92823642a8d83d837f14727768e25ef/layer.tar
ca199e68d96695bb0ecc4cc96bdbe84a9df44c1e43d05a72c68e9c6a6eb08362/
ca199e68d96695bb0ecc4cc96bdbe84a9df44c1e43d05a72c68e9c6a6eb08362/VERSION
ca199e68d96695bb0ecc4cc96bdbe84a9df44c1e43d05a72c68e9c6a6eb08362/json
ca199e68d96695bb0ecc4cc96bdbe84a9df44c1e43d05a72c68e9c6a6eb08362/layer.tar
d153df12d323b6dbdfc912d954b87b446631002d4ca5d13ee8071f2986b31024/
d153df12d323b6dbdfc912d954b87b446631002d4ca5d13ee8071f2986b31024/VERSION
d153df12d323b6dbdfc912d954b87b446631002d4ca5d13ee8071f2986b31024/json
d153df12d323b6dbdfc912d954b87b446631002d4ca5d13ee8071f2986b31024/layer.tar
ddf8ddc713b316164b90c7080accbfa733acbec6b1728966b83a0f248312c9fd/
ddf8ddc713b316164b90c7080accbfa733acbec6b1728966b83a0f248312c9fd/VERSION
ddf8ddc713b316164b90c7080accbfa733acbec6b1728966b83a0f248312c9fd/json
ddf8ddc713b316164b90c7080accbfa733acbec6b1728966b83a0f248312c9fd/layer.tar
e10e84e0794cf8731c62b5622682f51d8788ac23df1caaf377a7c1c9106ccfe6/
e10e84e0794cf8731c62b5622682f51d8788ac23df1caaf377a7c1c9106ccfe6/VERSION
e10e84e0794cf8731c62b5622682f51d8788ac23df1caaf377a7c1c9106ccfe6/json
e10e84e0794cf8731c62b5622682f51d8788ac23df1caaf377a7c1c9106ccfe6/layer.tar
e9a8f0d9df6a60005a249092a02d9da5a76cc5426b2ba8127636f3916df91dc7/
e9a8f0d9df6a60005a249092a02d9da5a76cc5426b2ba8127636f3916df91dc7/VERSION
e9a8f0d9df6a60005a249092a02d9da5a76cc5426b2ba8127636f3916df91dc7/json
e9a8f0d9df6a60005a249092a02d9da5a76cc5426b2ba8127636f3916df91dc7/layer.tar
ec03dde110a6f6ce17efe7d2de94295567b96a1a51550d8d0c852fde15b3de00/
ec03dde110a6f6ce17efe7d2de94295567b96a1a51550d8d0c852fde15b3de00/VERSION
ec03dde110a6f6ce17efe7d2de94295567b96a1a51550d8d0c852fde15b3de00/json
ec03dde110a6f6ce17efe7d2de94295567b96a1a51550d8d0c852fde15b3de00/layer.tar
f7c8540540c0ef44e6ba51a596a39612dce1b9ef7e5b62e5083f7d869e5e0581/
f7c8540540c0ef44e6ba51a596a39612dce1b9ef7e5b62e5083f7d869e5e0581/VERSION
f7c8540540c0ef44e6ba51a596a39612dce1b9ef7e5b62e5083f7d869e5e0581/json
f7c8540540c0ef44e6ba51a596a39612dce1b9ef7e5b62e5083f7d869e5e0581/layer.tar
faf07413a5d4cb3f026285e056b1e910ef0bf22504beed06a429001e12f4205e/
faf07413a5d4cb3f026285e056b1e910ef0bf22504beed06a429001e12f4205e/VERSION
faf07413a5d4cb3f026285e056b1e910ef0bf22504beed06a429001e12f4205e/json
faf07413a5d4cb3f026285e056b1e910ef0bf22504beed06a429001e12f4205e/layer.tar
repositories
此文件包含了鏡像重建所必須的全部層,能夠把它拷貝到其餘docker主機,使用docker load加載