Docker port forwarding not working

前端 未结 5 607
故里飘歌
故里飘歌 2020-12-14 17:17

I have setup Docker container for access my machine docker container to another machine in local.

Create a container below command:

    docker run -i         


        
5条回答
  •  庸人自扰
    2020-12-14 18:07

    Port 7000 on the host is redirecting to port 8000 in the container, but is anything listening on that port in the container?

    Your docker run command is a bit odd: -it is for running a container interactively with a terminal attached; -d is for running detached, in the background; bash at the end overrides whatever the image configures as the startup command, which is why I think there's nothing listening on port 8000.

    Try running the simplest NGINX container with this:

    docker run -d -p 8081:80 nginx:alpine
    

    And then verify you can get to the homepage:

    curl http://localhost:8081
    

    If that's working then I'd look at how you're running your image.

提交回复
热议问题