after mac has installed docker, follow the 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://192.168.99.102:2376 v18.05.0-ce
add to the environment
$ docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.102:2376"
export DOCKER_CERT_PATH="/Users/xushuainan/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
-sharp Run this command to configure your shell:
-sharp eval $(docker-machine env default)
Connect to the environment
eval "$(docker-machine env default)"
View ip
$ docker-machine ip default
192.168.99.102
create a nginx
docker run -d -p 8000:80 nginx
View nginx
$curl $(docker-machine ip default):8000
curl: (7) Failed to connect to 192.168.99.102 port 8000: Connection refused
Why is this?
also before, it is the same to create a mysql in docker. If you connect to the inside of the container, the mysql can be used, but it cannot be accessed from the outside through the ip in the vm.
ask the Great God for guidance.