我遵循文档页docker的一步步将其安装到我的ubuntu上。
成功安装 docker-ce 后,我在终端中收到以下消息:
Reading package lists... Done
Building dependency tree
Reading state information... Done
docker-ce is already the newest version (5:18.09.6~3-0~ubuntu-bionic).
0 upgraded, 0 newly installed, 0 to remove and 473 not upgraded.
问题:每当我在终端中运行以下命令时,我都会遇到no such file or directory
错误!
这是我在终端中执行的内容:
sudo apt-get install docker-ce=<5:18.09.6~3-0~ubuntu-bionic> docker-ce-cli=<5:18.09.6~3-0~ubuntu-bionic> containerd.io
答案1
在 bash(您最有可能使用的)中,波浪号 (~) 会被特殊处理。~
本身扩展到你的主目录,同时~user
扩展到用户的主目录。
要解决此问题,请引用 docker-ce 和 docker-ce-cli 参数:
sudo apt-get install "docker-ce=<5:18.09.6~3-0~ubuntu-bionic>" "docker-ce-cli:<5:18.09.6~3-0~ubuntu-bionic>" containerd.io
答案2
安装 Docker 的更好方法:
最近我发现有一种更好的方法docker
只需使用一个命令即可安装:
wget -qO- https://get.docker.com/ | sh
我的问题解决方案:我读了很多解决问题的文章,学到了很多东西,详细的解决方案在这关联。
答案是,每当我想使用 apt-get 时,它就被锁定了。所以我应该杀死其他不允许我访问该文件的进程。因此,通过输入以下命令,您可以看到进程及其编号:
ps ax | grep -i apt
查看进程 ID 后,可以使用以下命令终止进程:
sudo kill -9 <process id>
最终,我运行docker run hello-world
没有任何错误。
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/