1、下载安装最新版本docker
wget -qO- https://get.docker.com/ | sh
2、启动docker服务
sudo service docker start
3、查看docker版本,检查安装情况
sudo docker version
4、运行hello-world容器
执行sudo docker container run hello-world,第一次会自动下载hello-world镜像,输出如下:
[xxx@fedora src]$ sudo docker container run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:5122f6204b6a3596e048758cabba3c46b1c937a46b5be6225b835d091b90e46c
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/
5、不想每次都sudo
如果不想每次运行dokcer都要用sudo,需要添加非root用户到本地docker组:
sudo usermod -aG docker xxx
#添加xxx用户后需要重新登陆linux主机才能生效
重新登陆linux主机,才能生效
重新登陆linux主机,才能生效
(End)