ubuntu下安装docker

网上找了很多办法,如下方法测试有效

curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/intranet | sh -

然后会提示安装成功,

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 ipsg

Remember that you will have to log out and back in for this to take effect!

根据提示,当前用户添加到docker组。、

注销重新登录,测试docker是否安装成功:

docker run hello-world

测试报错:

Unable to find image 'hello-world ' locally ...

解决办法:
(1)、修改/etc/docker/daemon.json 文件

//1)在/etc/docker文件夹下执行:
sudo touch daemon.json

//2)修改/etc/docker/daemon.json 文件权限
chmod 777 daemon.json

//3)daemon.json文件中写入如下内容:
------------------
{ 
"registry-mirrors": ["https://alzgoonw.mirror.aliyuncs.com"] 
}

(2)、重启docker之后就可以了

//重启docker
sudo systemctl restart docker

//查看状态
sudo systemctl status docker

(3)再次运行测试

docker run hello-world

提示如下:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:e7c70bb24b462baa86c102610182e3efcb12a04854e8c582838d92970a09f323
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/

能够正常使用!

参考博客:
https://www.cnblogs.com/nthforsth/p/12257755.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值