Docker桌面安装在容器中失败,出现在/etc/hosts上..该怎么办?

huangapple go评论51阅读模式
英文:

Docker desktop install in container fails on /etc/hosts .. what do to?

问题

我正在尝试在容器内安装Docker引擎。

wget https://desktop.docker.com/linux/main/amd64/docker-desktop-4.16.2-amd64.deb
apt-get install -y ./docker-desktop-4.16.2-amd64.deb

一切都进行得很顺利,直到在安装后阶段,它尝试更新/kubernetes的/etc/hosts文件时失败了:

/var/lib/dpkg/info/docker-desktop.postinst: line 42: /etc/hosts: 只读文件系统

这是Docker内部构建的预期行为,因为它不允许修改容器的/etc/hosts文件。

是否有解决这个问题的方法?可以在安装Docker桌面时跳过这一步吗?或者还有其他方法吗?

英文:

I am trying to install docker engine inside a container.

wget https://desktop.docker.com/linux/main/amd64/docker-desktop-4.16.2-amd64.deb
apt-get install -y ./docker-desktop-4.16.2-amd64.deb

Everything goes fine until in the post install phase, it tries to update /ect/hosts files for the kubernetes. Here it fails:

/var/lib/dpkg/info/docker-desktop.postinst: line 42: /etc/hosts: Read-only file system

This is expected behaviour for docker build in that it does not allow to modify /etc/hosts of the container.

Is there a way to solve this? Install docker desktop without doing this step? Or any other way?

答案1

得分: 0

通过在构建命令中添加以下参数来解决了这个问题:

--add-host kubernetes.docker.internal:127.0.0.1

示例:
docker build --add-host kubernetes.docker.internal:127.0.0.1 -t stsjava2 .

英文:

I Solved this issue by adding this parameter in build

--add-host kubernetes.docker.internal:127.0.0.1

Example:
docker build --add-host kubernetes.docker.internal:127.0.0.1 -t stsjava2 .

huangapple
  • 本文由 发表于 2023年2月8日 23:53:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75388360.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定