即使与apt-get一起安装也找不到docker命令 [英] docker command not found even though installed with apt-get

查看:716
本文介绍了即使与apt-get一起安装也找不到docker命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

添加此内容以供他人参考,因为如果存在这样的答案,它可以为我节省10分钟。

Adding this for reference for others because it would have saved me 10 minutes if such an answer existed.

I尝试使用ubuntu 14.0LTS virtualbox安装Docker

I tried installing Docker using ubuntu 14.0LTS virtualbox

sudo apt get install docker

但是,当我尝试运行docker时,出现以下错误

However, when I try running docker it gives me the following error

当前未安装程序 docker。您可以通过键入以下命令进行安装:
sudo apt-get install docker

为什么ubuntu没有看到docker?

Why is ubuntu not seeing docker?

推荐答案

Ubuntu软件包 docker 实际上是指GUI应用程序,而不是受人喜爱的DevOps工具

The Ubuntu package docker actually refers to a GUI application, not the beloved DevOps tool we've come out to look for.

有关docker的说明,可按以下docker页面上的说明进行操作: https://docs.docker.com/engine/install/ubuntu/

The instructions for docker can be followed per instructions on the docker page here: https://docs.docker.com/engine/install/ubuntu/

===更新(感谢@Scott Stensland)===

您现在运行以下安装脚本来获取docker:

You now run the following install script to get docker:

`sudo curl -sSL https://get.docker.com/ | sh`



  • 注意:请查看网站上的脚本并确保您具有正确的链接

  • 这将运行安装docker的脚本。请注意脚本的最后一部分:

    This will run a script that installs docker. Note the last part of the script:

    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 stens`
    
    Remember that you will have to log out and back in for this to take effect!
    

    更新Docker运行:

    To update Docker run:

    `sudo apt-get update && sudo apt-get upgrade`
    

    有关正在发生的事情的更多详细信息,
    参见 docker安装说明文件或@Scott Stensland的回答

    For more details on what's going on, See the docker install documentation or @Scott Stensland's answer below

    ===更新:对于那些不喜欢sudo的人| sh ===

    在评论中有些提到,将任意脚本作为sudo运行是有风险的。上面的选项是docker提供的便捷脚本,用于简化任务。但是,对于那些注重安全性但又不想阅读脚本的人,可以执行以下操作:

    Some in the comments have mentioned that it a risk to run an arbitrary script as sudo. The above option is a convenience script from docker to make the task simple. However, for those that are security-focused but don't want to read the script you can do the following:


    1. 添加依赖项


    sudo apt-get update; \
    sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg-agent \
     software-properties-common
    



    1. 添加docker gpg键

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add-

    (安全检查,验证密钥指纹 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

    (Security check, verify key fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

    $ sudo apt-key fingerprint 0EBFCD88
    
    pub   rsa4096 2017-02-22 [SCEA]
          9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
    sub   rsa4096 2017-02-22 [S]
    


    1. 设置存储库


    sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"
    



    1. 安装Docker


    sudo apt-get update; \
    sudo apt-get install docker-ce docker-ce-cli containerd.io
    

    如果需要验证它是否正常运行:
    sudo docker hello-world

    If you want to verify that it worked run: sudo docker run hello-world

    以下说明了为什么这样命名:
    为什么要在ubuntu上安装docker应该是 sudo apt-get install docker.io?

    The following explains why it is named like this: Why install docker on ubuntu should be `sudo apt-get install docker.io`?

    这篇关于即使与apt-get一起安装也找不到docker命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆