blacsheep@blacsheep-myubuntu:~$ sudo su root@blacsheep-myubuntu:/home/blacsheep# wget -qO- https://get.docker.com/ sh # Executing docker install script, commit: 1d31602 + sh -c apt-get update -qq >/dev/null + sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null + sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" apt-key add -qq - >/dev/null + sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial edge" > /etc/apt/sources.list.d/docker.list + [ ubuntu = debian ] + sh -c apt-get update -qq >/dev/null + sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null + sh -c docker version Client: Version: 18.01.0-ce API version: 1.35 Go version: go1.9.2 Git commit: 03596f5 Built: Wed Jan 10 20:11:05 2018 OS/Arch: linux/amd64 Experimental: false Orchestrator: swarm
Server: Engine: Version: 18.01.0-ce API version: 1.35 (minimum version 1.12) Go version: go1.9.2 Git commit: 03596f5 Built: Wed Jan 10 20:09:37 2018 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 your-user
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.
root@blacsheep-myubuntu:/etc/docker# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a1ccf7c2927e ubuntu:16.10 "/bin/sh -c 'while t…" About a minute ago Up About a minute agitated_northcutt
然后docker logs a1ccf7c2927e 来查看
发现其实容器是在后台运行的
停止容器
为了停止我们刚刚的命令,我们运行
1 2 3 4 5
root@blacsheep-myubuntu:/etc/docker# docker stop a1ccf7c2927e7032498e1b7ba3a172b0110ced4b0418f10c3e156d0d235627f1 a1ccf7c2927e7032498e1b7ba3a172b0110ced4b0418f10c3e156d0d235627f1 root@blacsheep-myubuntu:/etc/docker# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES root@blacsheep-myubuntu:/etc/docker#