<p>Most likely the port is published on the VM and you are trying to connect to your laptop's IP and not seeing it. Newer versions of docker that use xhyve include some networking tricks to publish the port all the way to your laptop, but docker-machine with VirtualBox does not do this.</p>

<p>You can lookup the IP of your VM with <code>docker-machine ls</code> or see it in the variable <code>echo $DOCKER_HOST</code> and connect to port 8000 on that IP to reach your application.</p>

CC BY-SA 4.0
2019-04-25T13:49:33.703Z
I am using xhyve I got ip and made request using mapped port, but I have running more machines how to get other machines ip? `docker-machine ls` shows only one machine ip address
Kamal Panhwar
CC BY-SA 4.0
2019-04-25T14:05:52.020Z
If you have xhyve, then I don't believe you need docker-machine.
BMitch
CC BY-SA 4.0
2019-04-26T07:17:24.133Z
I am confused here, if I am not using VM than I can use xhyve but is docker-machine not required for both? as I used `brew install docker docker-compose docker-machine xhyve docker-machine-driver-xhyve` which installing both softwares.
Kamal Panhwar
CC BY-SA 4.0
2019-04-26T11:31:16.740Z
If you install directly from docker itself rather than brew, the latest releases run on top of xhyve with a LinuxKit based VM that is fairly transparent, much of the time you don't realize you're in a VM as you do with docker-machine.
BMitch
CC BY-SA 4.0
2019-04-25T13:26:52.473Z
2019-04-25T13:26:52.473Z
BMitch
<p>That shows that your docker service is not yet running . Try start the service</p>

<pre><code>open -a Docker
</code></pre>

CC BY-SA 4.0
2019-05-06T12:12:40.377Z
Well I figure out, and even compared to Docker.app and now shift to docker.app as brew installation and docker.app has not much difference to better to latest tools.
Kamal Panhwar
CC BY-SA 4.0
2019-05-05T16:59:44.097Z
2019-05-05T16:59:44.097Z
Fauzan
<p>I used brew to install docker, docker-machine and docker-compose. Everything is working, but when I use expose to map port on my host machine, it is not working.</p>

<p>When I ssh in docker machine service is running perfectly inside docker machine, but outside nothing coming up.</p>

<p>My software versions are </p>

<pre><code>Docker version 18.09.5, build e8ff056

docker-machine version 0.16.1, build cce350d

docker-compose version 1.24.0
</code></pre>

<p>and I am using <code>xhyve</code> for virtualization</p>

<p>Here is my Dockerfile</p>

<pre><code>FROM node
  LABEL maintainer xyz@gmail.com
  RUN git clone -q https://github.com/docker-in-practice/todo.git
  WORKDIR todo
  RUN npm install &gt; /dev/null
  EXPOSE 8000
  CMD ["npm", "start"]
</code></pre>

<p>I use following command to run docker </p>

<pre><code>docker run -i -t -p 8000:8000 --name example1 todoapp
</code></pre>

<p>I have read many article and noticed there is issues in docker and mac related, but not sure how can I solve it. Please any suggestion. I am not using mac docker app due to system resources limit.</p>

<p>I also read somewhere that I should use sudo than it should work, but I tried and get following error</p>

<pre><code>docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
</code></pre>

<p>I think sudo will require when port is below 1000 but my port is 8000 so I don't think I need sudo here.</p>

<docker><dockerfile><ports>
Docker not exposing port on mojave mac
Kamal Panhwar
# Docker not exposing port on mojave mac

(Asked by: username_0 on 2019-04-25)

I used brew to install docker, docker-machine and docker-compose. Everything is working, but when I use expose to map port on my host machine, it is not working.
When I ssh in docker machine service is running perfectly inside docker machine, but outside nothing coming up.
My software versions are 
Docker version 18.09.5, build e8ff056

docker-machine version 0.16.1, build cce350d

docker-compose version 1.24.0

and I am using xhyve for virtualization
Here is my Dockerfile
FROM node
  LABEL maintainer xyz@gmail.com
  RUN git clone -q https://github.com/docker-in-practice/todo.git
  WORKDIR todo
  RUN npm install > /dev/null
  EXPOSE 8000
  CMD ["npm", "start"]

I use following command to run docker 
docker run -i -t -p 8000:8000 --name example1 todoapp

I have read many article and noticed there is issues in docker and mac related, but not sure how can I solve it. Please any suggestion. I am not using mac docker app due to system resources limit.
I also read somewhere that I should use sudo than it should work, but I tried and get following error
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I think sudo will require when port is below 1000 but my port is 8000 so I don't think I need sudo here.

**Tags:** docker, dockerfile, ports


---

## 2 answers

### Answer by username_1 on 2019-04-25. Score: 2 | Accepted answer

Most likely the port is published on the VM and you are trying to connect to your laptop's IP and not seeing it. Newer versions of docker that use xhyve include some networking tricks to publish the port all the way to your laptop, but docker-machine with VirtualBox does not do this.

You can lookup the IP of your VM with `docker-machine ls` or see it in the variable `echo $DOCKER_HOST` and connect to port 8000 on that IP to reach your application.

> **Comments:**
> **username_0**: I am using xhyve I got ip and made request using mapped port, but I have running more machines how to get other machines ip? `docker-machine ls` shows only one machine ip address  
> **username_1**: If you have xhyve, then I don't believe you need docker-machine.  
> **username_0**: I am confused here, if I am not using VM than I can use xhyve but is docker-machine not required for both? as I used `brew install docker docker-compose docker-machine xhyve docker-machine-driver-xhyve` which installing both softwares.  
> **username_1**: If you install directly from docker itself rather than brew, the latest releases run on top of xhyve with a LinuxKit based VM that is fairly transparent, much of the time you don't realize you're in a VM as you do with docker-machine.  

---

### Answer by username_2 on 2019-05-05. Score: 0

That shows that your docker service is not yet running . Try start the service
open -a Docker

> **Comments:**
> **username_0**: Well I figure out, and even compared to Docker.app and now shift to docker.app as brew installation and docker.app has not much difference to better to latest tools.  

---

