Edit the /etc/default/grub file. Set the GRUB_CMDLINE_LINUX value as follows:
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" Save and close the file.
Update GRUB.
$ sudo update-grub Reboot your system.
运行 hello word容器
添加代理仓库-daocloud
1 2 3 4 5 6
root@ubuntu:~# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://172d594a.m.daocloud.io docker version >= 1.12 {"registry-mirrors": ["http://172d594a.m.daocloud.io"]} Success. You need to restart docker to take effect: sudo systemctl restart docker.service root@ubuntu:~# systemctl restart docker
root@ubuntu:~# docker run hello-world Unable to find image 'hello-world:latest' locally # 在本地没有找到该镜像 latest: Pulling from library/hello-world # 在远程仓库中查找镜像 78445dd45222: Pull complete # 拉取镜像 Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 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 ID: https://cloud.docker.com/
For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
查看容器状态
查看运行状态的容器
1 2 3 4
root@ubuntu:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES root@ubuntu:~#
查看所有状态的容器
1 2 3 4
root@ubuntu:~# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c6fd12bef22 hello-world "/hello" 4 minutes ago Exited (0) 4 minutes ago wizardly_mccarthy root@ubuntu:~#
更改容器名称
1 2 3 4 5
root@ubuntu:~# docker run --name "sayHi" hello-world root@ubuntu:~# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a74123af6f47 hello-world "/hello" 5 seconds ago Exited (0) 4 seconds ago sayHi 9c6fd12bef22 hello-world "/hello" 7 minutes ago Exited (0) 7 minutes ago wizardly_mccarthy