英文:
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 .
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论