安装docker命令
wget -qO- https://get.docker.com/ | sh
# Executing docker install script, commit: 2f4ae48
+ sudo -E sh -c apt-get update -qq >/dev/null
[sudo] sea 的密码:
+ sudo -E sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sudo -E sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - >/dev/null
Warning: apt-key output should not be parsed (stdout is not a terminal)
+ sudo -E sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" > /etc/apt/sources.list.d/docker.list
+ sudo -E sh -c apt-get update -qq >/dev/null
+ [ -n ]
+ sudo -E sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
+ sudo -E sh -c docker version
Client:
Version: 18.09.6
API version: 1.39
Go version: go1.10.8
Git commit: 481bc77
Built: Sat May 4 02:35:57 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.6
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 481bc77
Built: Sat May 4 01:59:36 2019
OS/Arch: linux/amd64
Experimental: false
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker sea
Remember that you will have to log out and back in for this to take effect!
WARNING: Adding a user to the "docker" group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.
sudo usermod -aG docker sea
ocker run hello-world
docker: 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.39/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
以管理运行出现如下问题:
sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
解决办法:
sudo vim /etc/docker/daemon.json
重启docker systemctl restart docker
systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
Active: active (running) since Sat 2019-06-15 20:51:00 CST; 25s ago
Docs: https://docs.docker.com
Main PID: 18873 (dockerd)
Tasks: 12
CGroup: /system.slice/docker.service
└─18873 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/contai
6月 15 20:50:59 ddh dockerd[18873]: time="2019-06-15T20:50:59.789737445+08:00" l
6月 15 20:50:59 ddh dockerd[18873]: time="2019-06-15T20:50:59.790037658+08:00" l
6月 15 20:50:59 ddh dockerd[18873]: time="2019-06-15T20:50:59.790224007+08:00" l
6月 15 20:50:59 ddh dockerd[18873]: time="2019-06-15T20:50:59.791190845+08:00" l
6月 15 20:50:59 ddh dockerd[18873]: time="2019-06-15T20:50:59.899740952+08:00" l
6月 15 20:50:59 ddh dockerd[18873]: time="2019-06-15T20:50:59.953502157+08:00" l
6月 15 20:51:00 ddh dockerd[18873]: time="2019-06-15T20:51:00.029950433+08:00" l
6月 15 20:51:00 ddh dockerd[18873]: time="2019-06-15T20:51:00.030059007+08:00" l
6月 15 20:51:00 ddh dockerd[18873]: time="2019-06-15T20:51:00.036562485+08:00" l
6月 15 20:51:00 ddh systemd[1]: Started Docker Application Container Engine.
udo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8
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.
(amd64)
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 ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/