此文为docker安装过程,安装说明文档参考:http://blog.csdn.net/zhaihaifei/article/details/51274164
安装过程:
login as: zhai
[email protected]'s password:
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 4.2.0-27-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Mon Apr 18 21:07:24 CST 2016
System load: 0.0 Processes: 77
Usage of /: 8.4% of 13.40GB Users logged in: 0
Memory usage: 2% IP address for eth0: 192.168.12.133
Swap usage: 0%
Graph this data and manage this system at:
https://landscape.canonical.com/
31 packages can be updated.
30 updates are security updates.
Last login: Mon Apr 18 21:07:24 2016
zhai@ubuntu:~$ sudo passwd
[sudo] password for zhai:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
zhai@ubuntu:~$ ls
zhai@ubuntu:~$ ifconfig -a
eth0 Link encap:Ethernet HWaddr 08:00:27:df:d4:e9
inet addr:192.168.12.133 Bcast:192.168.12.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:d4e9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:392 errors:0 dropped:0 overruns:0 frame:0
TX packets:125 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31740 (31.7 KB) TX bytes:22724 (22.7 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
zhai@ubuntu:~$ docker
The program 'docker' is currently not installed. You can install it by typing:
sudo apt-get install docker
zhai@ubuntu:~$ uname -a
Linux ubuntu 4.2.0-27-generic #32~14.04.1-Ubuntu SMP Fri Jan 22 15:32:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
zhai@ubuntu:~$ su -
Password:
root@ubuntu:~# apt-get update
Ign http://us.archive.ubuntu.com trusty InRelease
Get:1 http://us.archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Hit http://us.archive.ubuntu.com trusty-backports InRelease
Hit http://us.archive.ubuntu.com trusty Release.gpg
。。。
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Processing triggers for ca-certificates (20160104ubuntu0.14.04.1) ...
Updating certificates in /etc/ssl/certs... 19 added, 19 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.
root@ubuntu:~# exit
logout
zhai@ubuntu:~$ sudo apt-get install apt-transport-https ca-certificates
Reading package lists... Done
Building dependency tree
Reading state information... Done
ca-certificates is already the newest version.
apt-transport-https is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.Xo7Cl9wo2r --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
gpg: requesting key 2C52609D from hkp server p80.pool.sks-keyservers.net
gpg: key 2C52609D: public key "Docker Release Tool (releasedocker)
" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
zhai@ubuntu:~$
zhai@ubuntu:~$ sudo touch /etc/apt/sources.list.d/docker.list
zhai@ubuntu:~$ sudo vi /etc/apt/sources.list.d/docker.list
zhai@ubuntu:~$ sudo apt-get updae
E: Invalid operation updae
zhai@ubuntu:~$ sudo apt-get update
Ign http://us.archive.ubuntu.com trusty InRelease
Hit http://security.ubuntu.com trusty-security InRelease
Hit http://us.archive.ubuntu.com trusty-updates InRelease
Get:1 http://security.ubuntu.com trusty-security/main Sources [110 kB]
Hit http://us.archive.ubuntu.com trusty-backports InRelease
Hit http://us.archive.ubuntu.com trusty Release.gpg
Get:2 https://apt.dockerproject.org ubuntu-trusty InRelease
Ign https://apt.dockerproject.org ubuntu-trusty InRelease
Hit http://us.archive.ubuntu.com trusty-updates/main Sources
Hit http://security.ubuntu.com trusty-security/restricted Sources
Hit http://us.archive.ubuntu.com trusty-updates/restricted Sources
Hit http://us.archive.ubuntu.com trusty-updates/universe Sources
Hit http://us.archive.ubuntu.com trusty-updates/multiverse Sources
Get:3 https://apt.dockerproject.org ubuntu-trusty Release
Hit http://security.ubuntu.com trusty-security/universe Sources
Get:4 https://apt.dockerproject.org ubuntu-trusty/main amd64 Packages
Hit http://us.archive.ubuntu.com trusty-updates/restricted amd64 Packages
Hit http://us.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://us.archive.ubuntu.com trusty-updates/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com trusty-updates/main i386 Packages
Get:5 https://apt.dockerproject.org ubuntu-trusty/main i386 Packages
Hit http://us.archive.ubuntu.com trusty-updates/restricted i386 Packages
Hit http://security.ubuntu.com trusty-security/multiverse Sources
Hit http://us.archive.ubuntu.com trusty-updates/universe i386 Packages
Hit http://us.archive.ubuntu.com trusty-updates/multiverse i386 Packages
Hit http://us.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://us.archive.ubuntu.com trusty-updates/multiverse Translation-en
Get:6 https://apt.dockerproject.org ubuntu-trusty/main Translation-en_US
Hit http://us.archive.ubuntu.com trusty-updates/restricted Translation-en
Hit http://us.archive.ubuntu.com trusty-updates/universe Translation-en
Hit http://us.archive.ubuntu.com trusty-backports/main Sources
Hit http://us.archive.ubuntu.com trusty-backports/restricted Sources
Hit http://us.archive.ubuntu.com trusty-backports/universe Sources
Hit http://us.archive.ubuntu.com trusty-backports/multiverse Sources
Hit http://us.archive.ubuntu.com trusty-backports/main amd64 Packages
Hit http://us.archive.ubuntu.com trusty-backports/restricted amd64 Packages
Hit http://us.archive.ubuntu.com trusty-backports/universe amd64 Packages
Hit http://us.archive.ubuntu.com trusty-backports/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com trusty-backports/main i386 Packages
Ign https://apt.dockerproject.org ubuntu-trusty/main Translation-en_US
Hit http://us.archive.ubuntu.com trusty-backports/restricted i386 Packages
Ign https://apt.dockerproject.org ubuntu-trusty/main Translation-en
Hit http://us.archive.ubuntu.com trusty-backports/universe i386 Packages
Hit http://us.archive.ubuntu.com trusty-backports/multiverse i386 Packages
Hit http://us.archive.ubuntu.com trusty-backports/main Translation-en
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://us.archive.ubuntu.com trusty-backports/multiverse Translation-en
Hit http://security.ubuntu.com trusty-security/restricted amd64 Packages
Hit http://us.archive.ubuntu.com trusty-backports/restricted Translation-en
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://us.archive.ubuntu.com trusty-backports/universe Translation-en
Hit http://security.ubuntu.com trusty-security/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com trusty Release
Hit http://security.ubuntu.com trusty-security/main i386 Packages
Hit http://us.archive.ubuntu.com trusty/main Sources
Hit http://security.ubuntu.com trusty-security/restricted i386 Packages
Hit http://security.ubuntu.com trusty-security/universe i386 Packages
Hit http://security.ubuntu.com trusty-security/multiverse i386 Packages
Hit http://us.archive.ubuntu.com trusty/restricted Sources
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://us.archive.ubuntu.com trusty/universe Sources
Hit http://security.ubuntu.com trusty-security/multiverse Translation-en
Hit http://us.archive.ubuntu.com trusty/multiverse Sources
Hit http://security.ubuntu.com trusty-security/restricted Translation-en
Get:7 http://us.archive.ubuntu.com trusty-updates/main amd64 Packages [753 kB]
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://us.archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://us.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://us.archive.ubuntu.com trusty/main i386 Packages
Hit http://us.archive.ubuntu.com trusty/restricted i386 Packages
Hit http://us.archive.ubuntu.com trusty/multiverse i386 Packages
Hit http://us.archive.ubuntu.com trusty/main Translation-en
Hit http://us.archive.ubuntu.com trusty/main amd64 Packages
Hit http://us.archive.ubuntu.com trusty/multiverse Translation-en
Hit http://us.archive.ubuntu.com trusty/restricted Translation-en
Hit http://us.archive.ubuntu.com trusty/universe Translation-en
Ign http://us.archive.ubuntu.com trusty/main Translation-en_US
Ign http://us.archive.ubuntu.com trusty/multiverse Translation-en_US
Ign http://us.archive.ubuntu.com trusty/restricted Translation-en_US
Ign http://us.archive.ubuntu.com trusty/universe Translation-en_US
Hit http://us.archive.ubuntu.com trusty/universe i386 Packages
Hit http://us.archive.ubuntu.com trusty/multiverse amd64 Packages
Fetched 889 kB in 40s (21.7 kB/s)
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/main/source/Sources Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/trusty-updates/main/binary-amd64/Packages Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.
zhai@ubuntu:~$ sudo apt-get purge lxc-docker
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'lxc-docker' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
zhai@ubuntu:~$ apt-cache policy docker-engine
docker-engine:
Installed: (none)
Candidate: 1.11.0-0~trusty
Version table:
1.11.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.10.3-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.10.2-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.10.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.10.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.9.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.9.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.8.3-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.8.2-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.8.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.8.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.7.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.7.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.6.2-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.6.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.6.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.5.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
zhai@ubuntu:~$
zhai@ubuntu:~$ sudo apt-get install linux-image-extra-$(uname -r)
Reading package lists... Done
Building dependency tree
Reading state information... Done
linux-image-extra-4.2.0-27-generic is already the newest version.
linux-image-extra-4.2.0-27-generic set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
zhai@ubuntu:~$ apt-get install apparmor
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
zhai@ubuntu:~$ sudo apt-get install apparmor
Reading package lists... Done
Building dependency tree
Reading state information... Done
apparmor is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
zhai@ubuntu:~$ sudo apt-get install docker-engine^C
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$ sudo apt-get install docker-engine
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
aufs-tools cgroup-lite git git-man liberror-perl libsystemd-journal0
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk
gitweb git-arch git-bzr git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
aufs-tools cgroup-lite docker-engine git git-man liberror-perl
libsystemd-journal0
0 upgraded, 7 newly installed, 0 to remove and 3 not upgraded.
Need to get 14.3 MB/17.7 MB of archives.
After this operation, 95.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://apt.dockerproject.org/repo/ ubuntu-trusty/main docker-engine amd64 1.11.0-0~trusty [14.3 MB]
Fetched 14.3 MB in 7min 29s (31.8 kB/s)
Selecting previously unselected package libsystemd-journal0:amd64.
(Reading database ... 57666 files and directories currently installed.)
Preparing to unpack .../libsystemd-journal0_204-5ubuntu20_amd64.deb ...
Unpacking libsystemd-journal0:amd64 (204-5ubuntu20) ...
Selecting previously unselected package aufs-tools.
Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1_amd64.deb ...
Unpacking aufs-tools (1:3.2+20130722-1.1) ...
Selecting previously unselected package docker-engine.
Preparing to unpack .../docker-engine_1.11.0-0~trusty_amd64.deb ...
Unpacking docker-engine (1.11.0-0~trusty) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../liberror-perl_0.17-1.1_all.deb ...
Unpacking liberror-perl (0.17-1.1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a1.9.1-1ubuntu0.3_all.deb ...
Unpacking git-man (1:1.9.1-1ubuntu0.3) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a1.9.1-1ubuntu0.3_amd64.deb ...
Unpacking git (1:1.9.1-1ubuntu0.3) ...
Selecting previously unselected package cgroup-lite.
Preparing to unpack .../cgroup-lite_1.9_all.deb ...
Unpacking cgroup-lite (1.9) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Setting up libsystemd-journal0:amd64 (204-5ubuntu20) ...
Setting up aufs-tools (1:3.2+20130722-1.1) ...
Setting up docker-engine (1.11.0-0~trusty) ...
docker start/running, process 11171
Setting up liberror-perl (0.17-1.1) ...
Setting up git-man (1:1.9.1-1ubuntu0.3) ...
Setting up git (1:1.9.1-1ubuntu0.3) ...
Setting up cgroup-lite (1.9) ...
cgroup-lite start/running
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Processing triggers for ureadahead (0.100.0-16) ...
zhai@ubuntu:~$ which docker
/usr/bin/docker
zhai@ubuntu:~$ ps -ef | grep docker
root 11171 1 0 22:05 ? 00:00:00 /usr/bin/docker daemon --raw-logs
root 11180 11171 0 22:05 ? 00:00:00 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --runtime docker-runc
zhai 11340 1124 0 22:06 pts/0 00:00:00 grep --color=auto docker
zhai@ubuntu:~$ ifconfig -a
docker0 Link encap:Ethernet HWaddr 02:42:cc:b7:e0:70
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth0 Link encap:Ethernet HWaddr 08:00:27:df:d4:e9
inet addr:192.168.12.133 Bcast:192.168.12.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:d4e9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:44982 errors:0 dropped:0 overruns:0 frame:0
TX packets:21379 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:53049396 (53.0 MB) TX bytes:2171572 (2.1 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$ sudo service docker start
start: Job is already running: docker
zhai@ubuntu:~$
zhai@ubuntu:~$ docker version
Client:
Version: 1.11.0
API version: 1.23
Go version: go1.5.4
Git commit: 4dc5990
Built: Wed Apr 13 18:34:23 2016
OS/Arch: linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
zhai@ubuntu:~$
zhai@ubuntu:~$ sudo service docker start
start: Job is already running: docker
zhai@ubuntu:~$ sudo service docker restart
docker stop/waiting
docker start/running, process 11401
zhai@ubuntu:~$ ps -ef | grep docker
root 11401 1 3 22:08 ? 00:00:00 /usr/bin/docker daemon --raw-logs
root 11410 11401 0 22:08 ? 00:00:00 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --runtime docker-runc
zhai 11465 1124 0 22:08 pts/0 00:00:00 grep --color=auto docker
zhai@ubuntu:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
03f4658f8b78: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/userguide/
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$
zhai@ubuntu:~$ sudo groupadd dockersudo groupadd dockersudo groupadd docker^C
zhai@ubuntu:~$ sudo groupadd docker
groupadd: group 'docker' already exists
zhai@ubuntu:~$ cat /etc/group
group group-
zhai@ubuntu:~$ cat /etc/group
group group-
zhai@ubuntu:~$ cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:syslog,zhai
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:zhai
floppy:x:25:
tape:x:26:
sudo:x:27:zhai
audio:x:29:
dip:x:30:zhai
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:
sasl:x:45:
plugdev:x:46:zhai
staff:x:50:
games:x:60:
users:x:100:
nogroup:x:65534:
libuuid:x:101:
netdev:x:102:
crontab:x:103:
syslog:x:104:
fuse:x:105:
messagebus:x:106:
mlocate:x:107:
ssh:x:108:
landscape:x:109:
zhai:x:1000:
lpadmin:x:110:zhai
sambashare:x:111:zhai
docker:x:999:
zhai@ubuntu:~$ sudo usermod -aG docker ubuntu
usermod: user 'ubuntu' does not exist
zhai@ubuntu:~$ sudo usermod -aG docker zhai
zhai@ubuntu:~$ docker run hello-world
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
zhai@ubuntu:~$