您好,我是 docker 新手,正在尝试在 centos 7 环境中设置 docker。我已经使用https://docs.docker.com/install/linux/docker-ce/centos/安装了 docker ,然后尝试使用此https://docs.docker.com/engine/examples/dotnetcore运行一个站点/#build-and-run-the-docker-image。我试图在 locahost 和这些端口上的 docker ip 上执行 wget 无济于事。
这就是我已经执行的:
docker build -t aspnetapp .
docker run -it -d --name myapp aspnetapp
这是码头文件
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 64928
EXPOSE 44340
FROM microsoft/dotnet:2.1-sdk AS build
COPY . /app
WORKDIR /app
RUN dotnet restore "TestDocker.csproj"
FROM build AS publish
RUN dotnet publish "TestDocker.csproj" -c Release -o /app
FROM base AS final
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "TestDocker.dll"]
这可以完美地构建和运行
[root@local testSite]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b6044951aa7d aspnetapp "dotnet TestDocker.d…" 45 minutes ago Up 45 minutes 44340/tcp, 64928/tcp myapp
防火墙 D:
[root@local testdocker]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp9s0
sources:
services: ssh dhcpv6-client http https
ports: 44340/tcp 64928/tcp 443/tcp 80/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
我以为我可以直接从浏览器访问它,但我没有运气。即使某处有这方面的说明,也有人能指出我的方向。
这可能是问题吗
Dec 12 14:40:58 local.office firewalld[2591]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C POSTROUTING -p tcp -s 172.17.0.2 -d 172.17.0.2 --dport 64928 -j MASQUERADE' failed: iptables: No chain/target/match by that name.
Dec 12 14:40:58 local.office firewalld[2591]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C DOCKER -p tcp -d 0/0 --dport 80 -j DNAT --to-destination 172.17.0.2:64928 ! -i docker0' failed: iptables: No chain/target/match by that name.
Dec 12 14:42:36 local.office firewalld[2591]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.2 --dport 64928 -j ACCEPT' failed: iptables: Bad rule (does a matching rule exist in that chain?).
Dec 12 14:42:36 local.office firewalld[2591]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C POSTROUTING -p tcp -s 172.17.0.2 -d 172.17.0.2 --dport 64928 -j MASQUERADE' failed: iptables: No chain/target/match by that name.
Dec 12 14:43:18 local.office firewalld[2591]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C DOCKER -p tcp -d 0/0 --dport 64928 -j DNAT --to-destination 172.17.0.2:64928 ! -i docker0' failed: iptables: No chain/target/match by that name.