在我的项目中,当我用docker-compose启动时,apt-get无法从Dockerfile中工作。但是,当我用--network选项直接调用docker时,它确实有效。
以下是我的心声:
docker-compose.yml
version: '3'
services:
main:
build: main
network_mode: hostmain/Dockefile
FROM osrm/osrm-backend:v5.22.0
RUN apt-get update && apt-get install -y wget nodejs npm osmium-tool这会失败(apt-get无法查找域):
sudo docker-compose build main这样做是可行的:
sudo docker build main --network=host原因是什么,怎么解决?
主机系统为Ubuntu20.04。
编辑:自己修好了。嗯,不是它本身,但我不能指出我到底做了什么来修复它。我在前后更改/etc/docker/daemon.conf并重新启动。
“码头工人”的组成如下:
version: '3'
services:
main:
build: main就这样。main/Dockerfile
FROM osrm/osrm-backend:v5.22.0
RUN echo 123321 && cat /etc/resolv.conf # echo $number to prevent caching
RUN apt-get update && apt-get install osmium-tool/etc/docker/daemon.conf
{}/etc/default/docker
...
DOCKER_OPTS=" --dns 127.0.0.53"
...如果我正确理解文档,127.0.0.53是Ubuntu自己的DNS转发守护进程。
运行$ docker-compose build main会打印我:
Building main
Step 1/5 : FROM osrm/osrm-backend:v5.22.0
---> daceec677b86
Step 2/5 : RUN echo 32231 && cat /etc/resolv.conf
---> Running in d8c54a39faee
32231
# This file is managed by man:systemd-resolved(8). Do not edit.
...
# operation for /etc/resolv.conf.
nameserver <provider dns ip>
nameserver 8.8.8.8
nameserver 192.168.0.1
search <my wifi router>
Removing intermediate container d8c54a39faee
---> 4b07a0fcc889
Step 3/5 : RUN apt-get update && apt-get install osmium-tool
---> Running in 71a7c887af04
Get:1 http://security.debian.org/debian-security stretch/updates InRelease [53.0 kB]
Ign:2 http://deb.debian.org/debian stretch InRelease一切都正常。
发布于 2020-10-07 08:45:27
最新答复:
sudo firewall-cmd --zone=public --add-masquerade --permanent;
sudo firewall-cmd --reload
sudo systemctl restart docker
You can even get more granular with firewall-cmd rules using the answers found here.
这似乎从CentOS8的“新安装”中解决了这个问题。这个IP表规则与它有很多细微差别,但如果您需要高度敏感的安全考虑和设置,则可能需要this thread seems to really have all the details。
原来的答案:我在CentOS主机上找到了解决这个问题的方法:
https://github.com/gliderlabs/docker-alpine/issues/386#issuecomment-665123736
修改/etc/firewalld/firewalld.conf中的以下部分
...
# FirewallBackend
# Selects the firewall backend implementation.
# Choices are:
# - nftables (default)
# - iptables (iptables, ip6tables, ebtables and ipset)
##FirewallBackend=nftables
FirewallBackend=iptables
...然后:service firewalld restart
在那之后,当我在码头上运行docker-compose up ...时
发布于 2022-02-16 12:20:01
我在甲骨文虚拟机上也有同样的问题。在我的本地机器上工作的同样的码头建造没有在那里工作。我所要做的就是
sudo systemctl restart dockerhttps://stackoverflow.com/questions/64067437
复制相似问题