docker - 在专用服务器上的 docker 中运行 docker?
问题描述
我将在服务提供商的专用服务器上运行 docker。无法在此服务器上安装 docker。安装了 Apache、Git 等等。所以我尝试在容器中运行 docker。我将从 gitlab 注册表中提取一个 docker 映像并在子域中运行。我写了一个.gitlab-ci.yml。但我收到一条错误消息。
我找到了这个答案:
您不能 (*) 在 Docker 容器或映像中运行 Docker。您不能 (*) 在 Dockerfile 中启动后台服务。正如你所说,像 systemctl 和 service 这样的命令在 Docker 中的任何地方都不能(*)工作。在任何情况下,您都不能从 Dockerfile 中的任何位置使用任何主机系统资源,包括主机的 Docker 套接字。
我该如何解决这个问题?
$ sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
ERROR: Job failed: exit code 1
.gitlab-ci.yml
image: ubuntu:latest
before_script:
- apt-get update
- apt-get install -y apt-transport-https ca-certificates curl software-properties-common
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add
- apt-key fingerprint 0EBFCD88
- add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
stages:
- test
test:
stage: test
script:
- apt-get update
- apt-cache search docker-ce
- apt-get install -y docker-ce
- docker run -d hello-world
解决方案
你找到的答案......有点老了。有一些选项可以在容器中运行 systemd,也可以运行一些systemctl-replacement脚本。
但是,我不确定您真正想要安装什么应用程序。
推荐阅读
- javascript - jQuery 选择器不适用于数据表
- flutter - 'flutter packages get' 因 node_preamble 投诉而失败
- python-3.x - 未找到模块错误:没有名为 config 的模块
- java - 如何在Android上实现父子Recyclerview
- javascript - 规范化数据的最合适位置在哪里?
- python - 将 Django 查询集转换为列表或字典
- regex - 关于正则表达式中嵌套组的说明
- javascript - 使用数据属性对 div 进行排序
- c++ - 为什么我无法覆盖虚拟功能?
- node.js - Mozilla Firefox 浏览器 POST 和 PUT 请求不起作用(MEAN 项目)