Mac access doc-machineip error

  docker, question

After the mac installs docker, follow official documentation to operate docker-machine to create a local vm

$ docker-machine create --driver virtualbox default

Then check

$ docker-machine ls
 NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
 default   -        virtualbox   Running   tcp://           v18.05.0-ce

Add to environment

$ docker-machine env default
 export DOCKER_HOST="tcp://"
 export DOCKER_CERT_PATH="/Users/xushuainan/.docker/machine/machines/default"
 export DOCKER_MACHINE_NAME="default"
 # Run this command to configure your shell:
 # eval $(docker-machine env default)

Connect to environment

eval "$(docker-machine env default)"

View ip

$ docker-machine ip default

Create a nginx

docker run -d -p 8000:80 nginx

View nginx

$curl $(docker-machine ip default):8000
 curl: (7) Failed to connect to port 8000: Connection refused

Why is this? ? ?
Previously, mysql was also created in docker. mysql can be used when connected to the inside of the container, but it cannot be accessed from outside through ip in vm.
Ask the great god for guidance.

Naturally, the ip of the docker-machine pile of virtual machines is the ip that they communicate with each other. If you don’t believe you can enter one of the virtual machines, then see if you can ping the nginx service of the other machine.
Then you need to make these virtual machines into a cluster. My side is the Swarm cluster, and then you can run the service, and then you can host the port corresponding to the container internal port or something.