Port forwarding in docker-machine?

前端 未结 6 1840
一向
一向 2020-11-29 20:25

Since boot2docker is deprecated I\'ve switched to docker-machine but I don\'t know how to open a port from docker-machine. In bo

6条回答
  •  余生分开走
    2020-11-29 21:06

    With recent versions of machine, you can simply do (where default is the name of the machine):

    docker-machine ssh default -L 27017:localhost:27017
    

    This is a more temporary solution than the VM configuration change.

    Use the following variation to only forward ports in a background process:

    docker-machine ssh default -f -N -L 27017:localhost:27017
    
    • -f Requests ssh to go to background just before command execution.
    • -N Allow empty command (useful here to forward ports only)

提交回复
热议问题