On Linux you can access your running Docker container on localhost or remotely by publishing the desired port.
On macOS it will only give you access to the Docker container from the Docker-Machine it is running on, i.e. from
You can now access your Docker container on
Bonus: Accessing your Docker container from a remote computer.
By default, with
You can now access your Docker container on
On macOS it will only give you access to the Docker container from the Docker-Machine it is running on, i.e. from
docker-machine ip <machine_name>
. To access it on localhost, you can use ssh port forwarding:docker-machine ssh <machine_name> -fNTL <local_port>:localhost:<machine_port>
You can now access your Docker container on
localhost:<local_port>
.Bonus: Accessing your Docker container from a remote computer.
By default, with
ssh -L
, the local port is bound for local use only. You can use the bind _address
option to make your Docker container available publicly:docker-machine ssh <machine_name> -fNTL \*:<local_port>:<localhost>:<machine_port>
You can now access your Docker container on
<your_ip>:<local_port>
.
Well that's because docker-machine is a virtual machine running on OS-X... you'd better maintain your own Virtual Box image of Linux as a docker host IMO. This way you control the virtual network more easily among other things.
ReplyDeleteDocker-Machine creates Linux images on VirtualBox for you. Then you can tweak their network config from VirtualBox if you want. But with this little trick, you can just ignore that this virtual Linux is there.
Delete