Docker安装
[email protected]:~$ sudo apt-get update
Hit: http://mirrors.aliyun.com/ubuntu xenial InRelease
Hit: http://mirrors.aliyun.com/ubuntu xenial-updates InRelease
Hit: http://mirrors.aliyun.com/ubuntu xenial-backports InRelease
Hit: http://mirrors.aliyun.com/ubuntu xenial-security InRelease
Reading package lists... Done
[email protected]:~$ sudo apt-get install \
> apt-transport-https \
> ca-certificates \
> curl \
> software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
apt-transport-https is already the newest version ().
software-properties-common is already the newest version ().
The following additional packages will be installed:
libcurl3-gnutls
The following NEW packages will be installed:
curl
The following packages will be upgraded:
ca-certificates libcurl3-gnutls
upgraded, newly installed, to remove and not upgraded.
Need to get kB of archives.
After this operation, kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 ca-certificates all ~ [ kB]
Get: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 libcurl3-gnutls amd64 -1ubuntu2.5 [ kB]
Get: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 curl amd64 -1ubuntu2.5 [ kB]
Fetched kB in 2s ( kB/s)
Preconfiguring packages ...
(Reading database ... files and directories currently installed.)
Preparing to unpack .../ca-certificates_20170717~.1_all.deb ...
Unpacking ca-certificates (~) over (20160104ubuntu1) ...
Preparing to unpack .../libcurl3-gnutls_7.47.0-1ubuntu2.5_amd64.deb ...
Unpacking libcurl3-gnutls:amd64 (-1ubuntu2.5) over (-1ubuntu2.2) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.47.0-1ubuntu2.5_amd64.deb ...
Unpacking curl (-1ubuntu2.5) ...
Processing triggers for man-db (-) ...
Processing triggers for libc-bin (-0ubuntu9) ...
Setting up ca-certificates (~) ...
Setting up libcurl3-gnutls:amd64 (-1ubuntu2.5) ...
Setting up curl (-1ubuntu2.5) ...
Processing triggers for ca-certificates (~) ...
Updating certificates in /etc/ssl/certs...
added, removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Processing triggers for libc-bin (-0ubuntu9) ...
[email protected]:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
[email protected]:~$ sudo apt-key fingerprint 0EBFCD88
pub 4096R/0EBFCD88 --
Key fingerprint = 9DC8 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb) <[email protected]>
sub 4096R/F273FCD8 --
ruyul[email protected]:~$ sudo add-apt-repository \
> "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
> $(lsb_release -cs) \
> stable"
[email protected]:~$ sudo apt-get update
Get: https://download.docker.com/linux/ubuntu xenial InRelease [ kB]
Get: https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages [, B]
Hit: http://mirrors.aliyun.com/ubuntu xenial InRelease
Hit: http://mirrors.aliyun.com/ubuntu xenial-updates InRelease
Hit: http://mirrors.aliyun.com/ubuntu xenial-backports InRelease
Hit: http://mirrors.aliyun.com/ubuntu xenial-security InRelease
Fetched kB in 1s ( kB/s)
Reading package lists... Done
[email protected]:~$ sudo apt-get install docker-ce
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
aufs-tools cgroupfs-mount git git-man liberror-perl
Suggested packages:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
gitweb git-arch git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
aufs-tools cgroupfs-mount docker-ce git git-man liberror-perl
upgraded, newly installed, to remove and not upgraded.
Need to get MB of archives.
After this operation, MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get: http://mirrors.aliyun.com/ubuntu xenial/universe amd64 aufs-tools amd64 :+-1ubuntu1 [ kB]
Get: http://mirrors.aliyun.com/ubuntu xenial/universe amd64 cgroupfs-mount all [, B]
Get: http://mirrors.aliyun.com/ubuntu xenial/main amd64 liberror-perl all - [ kB]
Get: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 git-man all :-0ubuntu1.3 [ kB]
Get: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 git amd64 :-0ubuntu1.3 [, kB]
Get: https://download.docker.com/linux/ubuntu xenial/stable amd64 docker-ce amd64 ~ce-~ubuntu [ MB]
Fetched MB in 5s (, kB/s)
Selecting previously unselected package aufs-tools.
(Reading database ... files and directories currently installed.)
Preparing to unpack .../aufs-tools_1%3a3.2+-1ubuntu1_amd64.deb ...
Unpacking aufs-tools (:+-1ubuntu1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../cgroupfs-mount_1.2_all.deb ...
Unpacking cgroupfs-mount () ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_17.12.0~ce-~ubuntu_amd64.deb ...
Unpacking docker-ce (~ce-~ubuntu) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../liberror-perl_0.17-2_all.deb ...
Unpacking liberror-perl (-) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.7.4-0ubuntu1.3_all.deb ...
Unpacking git-man (:-0ubuntu1.3) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.7.4-0ubuntu1.3_amd64.deb ...
Unpacking git (:-0ubuntu1.3) ...
Processing triggers for libc-bin (-0ubuntu9) ...
Processing triggers for man-db (-) ...
Processing triggers for ureadahead (-) ...
Processing triggers for systemd (-4ubuntu19) ...
Setting up aufs-tools (:+-1ubuntu1) ...
Setting up cgroupfs-mount () ...
Setting up docker-ce (~ce-~ubuntu) ...
Setting up liberror-perl (-) ...
Setting up git-man (:-0ubuntu1.3) ...
Setting up git (:-0ubuntu1.3) ...
Processing triggers for libc-bin (-0ubuntu9) ...
Processing triggers for systemd (-4ubuntu19) ...
Processing triggers for ureadahead (-) ...
[email protected]:~$ docker --version
Docker version -ce, build c97c6d6
[email protected]:~$ docker version
Client:
Version: -ce
API version:
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec ::
OS/Arch: linux/amd64
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.35/version: dial unix /var/run/docker.sock: connect: permission denied
使用案例1
[email protected]:~$ sudo docker search tutorialNAME DESCRIPTION STARS OFFICIAL AUTOMATED
learn/tutorial
georgeyord/reactjs-tutorial This is the backend of the React comment box… [OK]
chris24walsh/flask-aws-tutorial Runs a simple flask webapp demo, with the op… [OK]
linkedin/photon-ml-tutorial An interactive tutorial of the Photon ML mac…
mhausenblas/kairosdb-tutorial GitHub fetcher for KairosDB tutorial [OK]
muli/gluon-tutorials-zh https://github.com/mli/gluon-tutorials-zh [OK]
camphor/python-tutorial camphor-/python-tutorial [OK]
fiware/tutorials.tourguide-app FIWARE Tour Guide App sample application [OK]
activeeon/par-connector-tutorial Do the par-connector tutorial with R. The tu… [OK]
microsoft/aci-tutorial-sidecar
starkandwayne/concourse-tutorial
krishnatest/docker-nodejs-tutorialkk docker-nodejs-tutorialkk
splicemachine/tutorial-spark-kafka-consumer Spark Streaming Tutorial
kidikarus/concourse-tutorial--tasks
lukasheinrich/quickana-tutorial Image for the analysis code built from https…
cloudboost/tutorial
schwamster/docker-tutorial
paulcos11/docker-tutorial docker tutorial [OK]
onekit/rest-tutorial REST API server-side tutorial. How to do it … [OK]
kobe25/docker-tutorial Docker Tutorial [OK]
microsoft/aci-tutorial-app
imiell/git--tutorial
joshuacox/rabbitmq-tutorials Rabbit MQ Tutorial Demos [OK]
starkandwayne/concourse-tutorial-ci
imiell/git-rebase-tutorial
[email protected]:~$ docker pull learn/tutorial
Using default tag: latest
Warning: failed to get default registry endpoint from daemon (Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.35/info: dial unix /var/run/docker.sock: connect: permission denied). Using system default: https://index.docker.io/v1/
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.35/images/create?fromImage=learn%2Ftutorial&tag=latest: dial unix /var/run/docker.sock: connect: permission denied
[email protected]:~$ sudo docker pull learn/tutorial
Using default tag: latest
latest: Pulling from learn/tutorial
aeb542: Pull complete
Digest: sha256:b82e7c2a72ad8ea89d58af5d1472e35dacd5b7233577483f58ff8f9338bd
Status: Downloaded newer image for learn/tutorial:latest
ruyulin@ruyulin-virtual-machine:~$ sudo docker run learn/tutorial echo "hello word"
hello word
使用案例2
[email protected]-virtual-machine:~$ sudo docker pull tobegit3hub/dockerized-openoffice
Using default tag: latest
latest: Pulling from tobegit3hub/dockerized-openoffice
a3ed95caeb02: Pull complete
a7e6041d: Pull complete
efaa2589827: Pull complete
ab1d3a3b: Pull complete
fb8c49f2308b: Pull complete
d5eb4a8d7cc5: Pull complete
f99831c16c08: Pull complete
c2acbdd5ad: Pull complete
fc6c: Pull complete
f375695: Pull complete
bbc6a743e55a: Pull complete
ea66947c: Pull complete
a6e7b17c996: Pull complete
a326fab453: Pull complete
a7c05add1: Pull complete
b46f7f7e7fb9: Pull complete
fdf582970: Pull complete
Digest: sha256:af9365943e6bcd2634d01e38f95b2d8787d9907419edf5136812f510cae59
Status: Downloaded newer image for tobegit3hub/dockerized-openoffice:latest
[email protected]-virtual-machine:~$ sudo docker run -d -p : tobegit3hub/dockerized-openoffice
c646b7e4858939151c8287ac5c0beba104ba700f0056f47ae9fbb8ef6763e5
访问:
http://127.0.0.1:6080/vnc.html
停止:sudo docker kill 容器id
[email protected]-virtual-machine:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c646b7e485 tobegit3hub/dockerized-openoffice "/startup.sh" minutes ago Up minutes /tcp, /tcp, :->/tcp condescending_morse
ba928f6829b learn/tutorial "echo 'hello word'" minutes ago Exited () minutes ago amazing_pike
cdf477c13091 hello-world "/hello" minutes ago Exited () minutes ago quizzical_snyder
cf6d27af13 hello-world "/hello" minutes ago Exited () minutes ago relaxed_goodall
[email protected]-virtual-machine:~$ sudo docker kill c646b7e485
c646b7e485
[email protected]-virtual-machine:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c646b7e485 tobegit3hub/dockerized-openoffice "/startup.sh" minutes ago Exited () seconds ago condescending_morse
ba928f6829b learn/tutorial "echo 'hello word'" minutes ago Exited () minutes ago amazing_pike
cdf477c13091 hello-world "/hello" minutes ago Exited () minutes ago quizzical_snyder
cf6d27af13 hello-world "/hello" minutes ago Exited () minutes ago
问题
**Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon. Is the docker daemon running on this host?**
解决:
’
是没有sudo,正确应该是 sudo docker