在 Docker 的文档页面上,所有示例命令都显示为不带sudo,如下所示:
docker ps
Run Code Online (Sandbox Code Playgroud)
在 Ubuntu 上,二进制文件称为docker.io. 没有 sudo 它也不起作用:
sudo docker.io ps
Run Code Online (Sandbox Code Playgroud)
如何配置 Docker 以便我不需要在每个 Docker 命令前添加 sudo 前缀?
我想通过 ssh 或 bash 进入正在运行的 docker 容器。请看例子:
$ sudo docker run -d webserver
webserver is clean image from ubuntu:14.04
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
665b4a1e17b6 webserver:latest /bin/bash ... ... 22/tcp, 80/tcp loving_heisenberg
Run Code Online (Sandbox Code Playgroud)
现在我想得到这样的东西(进入正在运行的容器):
$ sudo docker run -t -i webserver(或者也许665b4a1e17b6相反)
$ root@665b4a1e17b6:/#
但是,当我运行上面的行时,我得到了新的 CONTAINER ID:
$ root@42f1e37bd0e5:/#
Run Code Online (Sandbox Code Playgroud)
我使用了 Vagrant,我想获得与vagrant ssh.
我想在带有 Ubuntu 16.04 映像的docker环境中安装certbot:
例如:
docker run -it ubuntu:16.04 /bin/bash
Run Code Online (Sandbox Code Playgroud)
当我在容器内时,安装 certbot 的最直接方法不起作用,因为它需要用户干预:
apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y -u ppa:certbot/certbot && \
apt-get install -y certbot
Run Code Online (Sandbox Code Playgroud)
问题是tzdata,这个交互式对话框停止了:
Extracting templates from packages: 100%
Preconfiguring packages ...
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they …Run Code Online (Sandbox Code Playgroud) 我按照此处的卸载说明进行操作。然后我运行了这些命令:
sudo apt-get purge docker-engine
sudo apt-get autoremove --purge docker-engine
rm -rf /var/lib/docker
Run Code Online (Sandbox Code Playgroud)
所以在我完成所有这些之后,我运行了这个命令来查看 docker 文件是否在其他任何地方:
sudo find / -name '*docker*'
Run Code Online (Sandbox Code Playgroud)
我发现了几个 docker 文件仍然存在的地方。
/etc
/sys
/lib
/usr
/usr
/run
/proc
/var
Run Code Online (Sandbox Code Playgroud)
Docker 存在于上述列表中的子文件夹中。如果您愿意,我可以发布每条路径。大约有200个地点。
有没有办法在任何地方完全彻底地删除 docker?
我输入 docker.io version,然后得到:
Client version: 0.9.1
Go version (client): go1.2.1
Git commit (client): 3600720
Server version: 0.9.1
Git commit (server): 3600720
Go version (server): go1.2.1
Last stable version: 0.11.1, please update docker
Run Code Online (Sandbox Code Playgroud)
我用一个apt-get update, 然后是: apt-get upgrade, or apt-get upgrade docker.io, 但它给我的只是:
docker.io is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Run Code Online (Sandbox Code Playgroud)
我正在运行 Ubuntu 14.04(可信)64 位服务器。
编辑:我想我在这个帖子评论中使用了一个脚本来安装 docker(因为它声称允许我只输入 docker 而不是 docker.io)
在最近的 c't(可悲的是付费墙)中有一篇关于 Snap 和 Flatpak 的文章。
这听起来与 Docker 非常相似,很多概念是相同的。现在我的问题是 Snap 和 Docker 之间有什么区别?这些是不同的用例吗?
我正在尝试systemctl在ubuntu:16.04docker 容器中使用该命令。我正在运行以下命令...
systemctl status ssh
Run Code Online (Sandbox Code Playgroud)
但是我收到错误...
Failed to connect to bus: No such file or directory
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?这与在 docker 容器中运行的 Ubuntu 相关吗?我怎样才能systemctl正常工作?
被netstat删除了16.04?是否有另一种netstat可用的16.04?或者我怎么安装netstat的16.04?
我正在运行一个ubuntu:16.04容器docker for Windows,它似乎netstat不再可用...它在一个ubuntu:14.04容器中可用。
我试过安装 netstat ,apt-get但没有运气......
apt-get update
Run Code Online (Sandbox Code Playgroud)
...
apt-get install netstat
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package netstat
Run Code Online (Sandbox Code Playgroud)
对于大多数开发人员来说,这个问题的解决方案可能很明显,但是 Linux 对我来说很新……非常享受它!
我正在遵循Ubuntu 上 docker-ce的官方 Docker 安装指南。
当我到达时,sudo apt install docker-ce我得到E: Package 'docker-ce' has no installation candidate:
$ sudo apt-get update
Hit:1 http://gb.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://gb.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://gb.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Reading package lists... Done
$ sudo apt-get install \
> apt-transport-https \
> ca-certificates \
> curl \
> software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
ca-certificates is already the newest version (20180409).
curl …Run Code Online (Sandbox Code Playgroud) 我刚刚安装了 docker 并创建了一个组并将我的用户名添加到其中以避免每次都使用 sudo。但是,当我进行测试并运行时,docker run hello-world它会出现以下错误:
WARNING: Error loading config file:/home/user/.docker/config.json - stat /home/user/.docker/config.json: permission denied
但随后它继续并给出了一个成功的信息:Hello from Docker.
This message shows that your installation appears to be working correctly.
任何想法有什么问题,它有什么影响?
docker ×10
16.04 ×3
apt ×2
container ×2
server ×2
18.04 ×1
automation ×1
bash ×1
letsencrypt ×1
netstat ×1
networking ×1
permissions ×1
snap ×1
ssh ×1
systemd ×1
ubuntu-core ×1